为什么文件创建时间少于创建文件之前测量的时间?
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
答案 0 :(得分:0)
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