[英]Mismatch between file creation time and current time in Python
为什么文件创建时间少于创建之前测量的时间?
import os, time
before_creation = time.time()
with open('my_file', 'w') as f:
f.write('something')
creation_time = os.stat('my_file').st_ctime
print(before_creation) # 1545031532.8819697
print(creation_time) # 1545031532.8798425
print(before_creation < creation_time) # False
编辑操作系统是Linux
eg., 1545073155.03
print(os.stat('my_file'))
我们得到 posix.stat_result(st_mode=33204, st_ino=12, st_dev=1792, st_nlink=1, st_uid=488, st_gid=487, st_size=0, st_atime=1545073155, st_mtime=1545073155, st_ctime=1545073155)
print(os.stat('my_file')[9])
我们得到1545073155
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.