有人用 python 完成过这个吗?
这是我目前所拥有的...
if os.path.isdir(options.map_file_directory):
searchedfile = glob.glob("*.map")
files = sorted( searchedfile, key = lambda file: os.path.getctime(file))
for i in files:
print("{} - {}".format(i, time.ctime(os.path.getctime(i))) )
最佳答案
解决了我自己的问题。与我“四处游荡”的方式有关
if os.path.isdir(options.map_file_directory):
print ("this is a test 4")
searchedfile = glob.glob(r'{}\*.map'.format(options.map_file_directory))
files = sorted( searchedfile, key = lambda file: os.path.getctime(file))
for i in files:
print("{} - {}".format(i, time.ctime(os.path.getctime(i))) )
关于python - 按创建日期的顺序打印目录的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32464533/