获取文件的时间戳和最近修改的副本

时间:2017-11-23 17:25:42

标签: python python-3.x

我正在读取文件并检查该文件中条目的时间戳...我想检查时间戳以及是否已使用{/ home / admin / backup}

从文件中修改时间戳
#!/usr/bin/python3
import argparse
import os


parser = argparse.ArgumentParser()
parser.add_argument('-c', default="config.dat", help='file to read the config from')
args = parser.parse_args()

#this reads and prints times okay

f = open('config.dat','r')
list_contents = f.read().split('\n')
for a in list_contents:
    b = os.path.getmtime(a)


#problem is here. 



cache = dict((a, os.path.getmtime(a)) for a in list_contents)
print('cache')

#if file recently modified then do this next code:....

0 个答案:

没有答案