我能够检索具有类似名称的文件列表。我要做的是检索最新的文件以便进行操作。使用glob,我可以检索所有文件,但不能检索特定的文件。你知道吗
这是我的示例代码:
permissionCurrentDate = '\n'.join(glob.iglob(os.path.join("PermissionsOnSystems*")))
打印结果如下:
PermissionsOnSystems2.txt
PermissionsOnSystems20170313-144036.txt
我想要的只是PermissionsOnSystems20170313-144036.txt
。你知道吗
我该怎么做?你知道吗
谢谢!你知道吗
根据您是从访问时间、元数据更改时间还是修改时间的角度查看最新文件,您可以使用
os.path.getatime
、os.path.getctime
或os.path.getmtime
。比如:相关问题 更多 >
编程相关推荐