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 版本,以及可能的其他因素。