import os
import time
def keep_file(work_path):
'''
params workpath : files root path
--- work_path_01
---file1
---file2
---file3
---work_path_02
'''
for root, dirs, files in os.walk(work_path):
for file in files:
abs_path = os.path.join(root, file)
file_time = os.stat(abs_path).st_mtime
file_modify_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(file_time))
print(file_modify_time )
if __name__ == '__main__':
root_path = r'F:\kidney_tumor_biaozhu\refine_data\mask'
case_list = os.listdir(root_path)
case_list.sort()
for case in case_list:
keep_file(os.path.join(root_path, case))
Python time 获取文件修改时间
最新推荐文章于 2024-05-30 14:12:08 发布