Getting file size in Python? [duplicate]
Use os.path.getsize(path)
which will
Return the size, in bytes, of path. Raise
OSError
if the file does not exist or is inaccessible.
import osos.path.getsize('C:\\Python27\\Lib\\genericpath.py')
Or use os.stat(path).st_size
import osos.stat('C:\\Python27\\Lib\\genericpath.py').st_size
Or use Path(path).stat().st_size
(Python 3.4+)
from pathlib import PathPath('C:\\Python27\\Lib\\genericpath.py').stat().st_size