我的代码:
import os
from datetime import datetime
now = str(datetime.now())
with open('now.txt', 'w') as f:
f.write(now + '\n')
print('now:', now)
print()
print('stat:')
os.system('stat now.txt')
输出示例如下:
now: 2018-10-07 06:22:52.293084
stat:
File: now.txt
Size: 27 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 543300 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ susam) Gid: ( 1000/ susam)
Access: 2018-10-07 02:58:04.219272291 +0000
Modify: 2018-10-07 06:22:52.288283252 +0000
Change: 2018-10-07 06:22:52.288283252 +0000
Birth: -
输出和程序似乎表明文件是在2018-10-07 06:22:52.293084
或之后创建的,但是根据stat
输出的文件修改时间是过去的:2018-10-07 06:22:52.288283
。这怎么可能?