python - 如何打印以使用 python 开头的最新文件?
问题描述
是否可以使用打印最新文件startswith
?示例:以“DOG”开头
import subprocess
import os
import glob
list_of_files = glob.iglob("C:\Users\Guest\Desktop\OJT\scanner\*")
latest_file =
print latest_file
解决方案
我不知道你的意思是什么startswith
,但试试这个:
files = glob.iglob(r"C:\Users\Guest\Desktop\OJT\scanner\*")
latest_file = max(files, key=os.path.getctime)
推荐阅读
- c++ - 如何在 Visual Studio 上将输入的开始和结束与 std::regex 匹配
- powershell - Active Directory - 在 PowerShell 中使用用户主体名称重置用户密码
- r - 加入有关四键的信息以平铺 shapefile
- javascript - 如何将字符串脚本标签呈现为 React 组件?
- javascript - Prisma 追随者/追随者关系模式
- python - 将python函数转换为cython
- rust - 我可以简化使用双重引用的元组表达式吗?
- python - pandas groupby 到字典列表
- javascript - 如何对具有两个条件的列表进行排序
- javascript - 为什么单击空白区域时内容会消失?