demand (economics)
Requirements Find word documents in a folder within a certain date interval, all the word name and path to list, such as July 5 to July 31, all word documents under the D disk.
Modify the file type
Modify the file path
Retrieve document modification time interval
#conding=utf8 import os import time g = (r"F:\ Learning Materials\week_home") def judge_time_file(path, file, update_time): if not (('.doc','.docx')): return False start_time = (('2020-04-12 00:00:00', "%Y-%m-%d %H:%M:%S")) end_time = (('2020-05-23 00:00:00', "%Y-%m-%d %H:%M:%S")) # print(start_time , update_time , end_time) if start_time < update_time < end_time: return True return False data_list = [] for path, dir_list, file_list in g: for file_name in file_list: local_time = ((path, file_name)).st_mtime if judge_time_file(path, file_name, local_time): data_list.append([(path, file_name), ("%Y-%m-%d %H:%M:%S",(local_time))]) data_list.sort(key=lambda x:x[1]) print(*data_list, sep='\n')
summarize
to this article on how python traverses the specified path to all the files (according to the time interval retrieval) of the article is introduced to this, more related python traverses the specified path to all the files content please search for my previous posts or continue to browse the following articles hope that you will support me in the future more!