python finds all files in the specified folder and arranges them in reverse chronological order
- 2020-12-21 18:07:06
- OfStack
The code is as follows:
import os, glob, time
def search_all_files_return_by_time_reversed(path, reverse=True):
return sorted(glob.glob(os.path.join(path, '*')), key=lambda x: time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(os.path.getctime(x))), reverse=reverse)