← Go Back

How to Get File Size

The modern, object-oriented approach is using the pathlib standard module:

>>> import pathlib
>>> p = pathlib.Path("C:/python312/python.exe")
>>> p.stat().st_size
103192

Note that st_size is expressed in bytes.

pathlib files


🐍 You might also find interesting: