Why does os.path.getsize() return a negative number for a 10gb file?

后端 未结 2 1945
情话喂你
情话喂你 2021-01-12 14:16

I am using the function os.path.getsize() which gives the size of the file in bytes.

As my one file size is 10gb it give me size in negative(bytes).

2条回答
  •  不要未来只要你来
    2021-01-12 14:49

    Looks like an overflow of 32-bit int used for size which is limited to 4GB. This may be a bug (or even a missing compilation flag) in your particular version of Python. I just tried it in a 32-bit Linux box, using python 2.4 and 2.6; both give correct results on files bigger than 4GB.

    Try upgrading your Python; the fix is probably a minor version away.

提交回复
热议问题