📜  python 从任何目录获取最新编辑的文件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:50.382000             🧑  作者: Mango

代码示例1
from os.path import expanduser
import os
home = expanduser("~")
latest_edited_folder = max([f for f in os.scandir(home)], key=lambda x: x.stat().st_mtime).name
search_on = home+'\\'+latest_edited_folder
latest_edited_file = max([f for f in os.scandir(search_on)], key=lambda x: x.stat().st_mtime).name