Python Tutorial: 4 Methods to Getting the File Size in Python
OS module in Python comes as built-in, and it provides various utility methods to interact with operating system features. The popular ways to fetch file size in Python are as follows: Get file size using os.path.getsize() and seek(). If the function cannot find the file or is inaccessible, Python will raise an [OSError] If you have something like file-like objects, you could use `seek() and tell() to fetch the file size. The other methods perfectly work in the case of an actual file.