How to Get the Size of a File in Python

How to Get the Size of a File in Python


  • How to Get the Size of a File in Python

    Arinze Ugwu

    Arinze is an experienced Data Scientist (ML), driven by a strong desire to solve business challenges with Advanced technologies. He is also passionate about sharing knowledge through technical writing.

Frequently Asked Questions

This is an inbuilt module that aids with a user's interaction with the operating system and obtains information.

The scandir function can be used to get the individual files, after which any of the methods above can be applied to get the size of any file needed.

The OS module can be used by importing it.

To get the size of a folder, the sizes of files in the folder can be obtained and summed up.

The file size is in bytes by default but can be further converted to KB, MB or GB.

By default, the size is given in bytes. However, it can be converted to KB, MB or GB, divided by the equivalent size.

View more FAQs


What’s up with Turing? Get the latest news about us here.


Know more about remote work. Checkout our blog here.


Have any questions? We’d love to hear from you.

Hire remote developers

Tell us the skills you need and we'll find the best developer for you in days, not weeks.