Helpful Python Methods
import osdef getFreeSpace(path):
# Gets the number of free bytes in the given path
# Gets the number of free bytes in the given path
st = os.statvfs(path)
return st.f_bsize * st.f_bavaildef getFileSize(filepath):
# Gets the size of the file in bytes
try:
st = os.stat(filepath)
except IOError:
print "Failed to get size of", filepath
else:
return st[6]
0 Comments:
Post a Comment
<< Home