How to get the size of file in python?
I must learn to use google to solve problems. Input "python get file size" in google.
solution:
command line: input python, into:
>>> import os
>>> statinfo = os.stat('somefile.txt') # filename
>>> statinfo
(33188, 422511L, 769L, 1, 1032, 100, 926L, 1105022698,1105022732, 1105022732)
>>> statinfo.st_size
926L # size of somefile.txt
input: os.stat ("temp"),
posix.stat_result(st_mode=33188, st_ino=279987L, st_dev=2049L, st_nlink=1, st_uid=1000, st_gid=1000, st_size=1316889L, st_atime=1340701004, st_mtime=1340701837, st_ctime=1340701837)
>>> sinfo = os.stat("temp")
>>> output("Length: %s" % sinfo.st_size) # size of temp
>>>import os
>>> statinfo = os.stat('somefile.txt')
>>> statinfo
(33188,422511L,769L,1,1032,100,926L,1105022698,1105022732,1105022732)
>>> statinfo.st_size
926L