我想根据创建日期对一些文件进行排序。我使用os库中的getctime函数。我的代码似乎没用...我可能做错了。但是,如果我理解getctime函数,它应该可以工作...“返回系统的ctime,在某些系统(例如Unix)上,它是最后一次元数据更改的时间,而在其他系统(例如Windows)上,是系统的创建时间。路径。返回值是一个数字,给出自历元以来的秒数。
'''python
##getting creating date time
creation_date_list = []
for file_name in list_file_name:
path_file = os.path.join(PATH,file_name)
creation_date_list.append(os.path.getctime(path_file))
creation_date_list.sort()
for element in creation_date_list:
creation_date_temp = 0
index = 0
temp_list = []
while(creation_date_temp != element):
path_file = os.path.join(PATH,list_file_name[index])
creation_date_temp = os.path.getctime(path_file)
index = index+1
temp_list.append(list_file_name[index-1])
temp_list.append(element)
list_detailed_file.append(temp_list)
'''
它应该给我一个按照创建日期排序的文件名列表。我做错了吗?
非常感谢您