Python @ DjangoSpin

Python: Getting size of a file on disk

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon
Reading Time: 1 minutes

Getting size of a file on disk in Python: Using the stat() function of builtin module os, you can retrieve information about a file on disk, including its size in bytes.

Getting size of a file on disk in Python

import os

info = os.stat('textOne.txt')

print(info.st_size)                             # returns size of file in bytes

See also:

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon

Leave a Reply