获取某路径下最新的文件夹

One liner to find latest

# Find latest
import os, glob
max(glob.glob(os.path.join(directory, '*/')), key=os.path.getmtime)

One liner to find n’th latest

# Find n'th latest
import os, glob
sorted(glob.glob(os.path.join(directory, '*/')), key=os.path.getmtime)[-n]

credits: Prem Anand

阅读量: | 柯西君_BingWong | 2023-02-16