How to get file size in Python?

How to get a file’s size in Python from the full path of a file?

You can use this piece of Python code:


It returns the size in bytes. It raises os.error if the file does not exist or is inaccessible.

Manual of os.path.getsize():

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *