본문 바로가기
python

python check filesize os.path.getsize

by 타닥타닥 토다토닥 부부 2023. 7. 31.
반응형

python check filesize os.path.getsize

 

return byte

import os
memory = os.path.getsize("sample.jpg")
print(str(memory) + " byte")

# out : 224967 byte

 

return Kilobytes

print(str(memory/1024) + " kb")

# out : 219.6943359375 kb

 

return MegaBytes

print(str(memory/(1024*1024)) + " mb")

# out : 0.21454524993896484 mb

 

return GigaBytes

print(str(memory/(1024*1024*1024)) + " gb")

# out : 0.00020951684564352036 gb
반응형

댓글