Python 返回的文件大小与操作系统属性不同[重复]

问题描述 投票:0回答:1

我正在尝试使用 python 获取名为

fGDB.gdb
的文件的大小。但是虽然 Windows 属性将文件大小显示为
146 KB (150,399 bytes)

enter image description here

使用此代码

import os

gdb = r"C:\Users\...\....\fGDB.gdb"
file_size = os.path.getsize(gdb)
print("File Size is :", file_size, "bytes")

返回此:

File Size is : 12288 bytes

有人可以告诉我为什么大小不同以及如何通过 Python 获得显示在操作系统属性窗口上的确切数字吗?

python windows windows-explorer python-os
1个回答
0
投票

您可以提取已缓存的文件吗?

© www.soinside.com 2019 - 2024. All rights reserved.