gpt4 book ai didi

python - 按创建日期的顺序打印目录的内容

转载 作者:行者123 更新时间:2023-11-28 18:36:02 25 4
gpt4 key购买 nike

有人用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com