Python Tutorial: 4 Methods to Getting the File Size in Pythonby@itsmycode

Python Tutorial: 4 Methods to Getting the File Size in Python

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

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.

Company Mentioned

Mention Thumbnail
featured image - Python Tutorial: 4 Methods to Getting the File Size in Python
Srinivas Ramakrishna HackerNoon profile picture

@itsmycode

Srinivas Ramakrishna

Solution Architect having 14+ Years of Experience in .NET Core, Python, Node.JS, JavaScript, Cloud (Azure), RDBMS


Receive Stories from @itsmycode

react to story with heart
Srinivas Ramakrishna HackerNoon profile picture
by Srinivas Ramakrishna @itsmycode.Solution Architect having 14+ Years of Experience in .NET Core, Python, Node.JS, JavaScript, Cloud (Azure), RDBMS
catchsrinivas

RELATED STORIES

L O A D I N G
. . . comments & more!