Windows 上的 os.stat()

2023-11-22

属于哪些领域os.stat()Windows 上填充了虚拟值?

python 文档对此并不清楚。特别是,什么是st_inoWindows 上的产量?

有人可以在 Windows 上运行交互式 python 会话并让我知道吗?我没有 Windows 机器,所以我无法做到这一点。


st_ino, st_dev, st_nlink, st_uid, and st_gid是 Windows 7 SP1 上的虚拟变量Python 2.7.11:

import os; os.stat('Desktop\test.txt')
nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0L, st_nlink=0, st_uid=0, st_gid=0, st_size=293L, st_atime=1448376581L, st_mtime=1451782006L, st_ctime=1448376581L)

然而,从 Windows 7 SP1 开始,它们似乎填充了有意义的值Python 3.5.1:

import os; os.stat('Desktop\test.txt')
os.stat_result(st_mode=33206, st_ino=17732923532870243, st_dev=2289627604, st_nlink=2, st_uid=0, st_gid=0, st_size=293, st_atime=1448376581, st_mtime=1451782006, st_ctime=1448376581)

有关此主题的 Python 文档将引导理智的用户避免使用os.stat在 Windows 中,因为不能保证any字段将永远/永远准确。在实践中,它看起来像st_size, st_atime, st_mtime, and st_ctime通常(如果不总是)准确。其他字段至少取决于 Python 版本,可能还取决于 Windows 版本,以及可能的其他因素。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Windows 上的 os.stat() 的相关文章

随机推荐