Python 如何搜索过去 24 小时内创建的文件?
In Python how do I search for files created in the past 24 hours?
我是 python 的新手,我想在过去 24 小时内创建的目录中查找所有文件。如何过滤 24 小时内创建的文件 window.
此代码将在 Windows 计算机上的 Python 2.7 中使用。
获取文件的状态然后检查它是否少于 24 小时...
您将需要做 loop/recreation...
import os
import time
st = os.stat("test.py")
ctime = st.st_ctime
print time.time() - ctime/3600 // hours
if mtime<24:
print mtime
我是 python 的新手,我想在过去 24 小时内创建的目录中查找所有文件。如何过滤 24 小时内创建的文件 window.
此代码将在 Windows 计算机上的 Python 2.7 中使用。
获取文件的状态然后检查它是否少于 24 小时... 您将需要做 loop/recreation...
import os
import time
st = os.stat("test.py")
ctime = st.st_ctime
print time.time() - ctime/3600 // hours
if mtime<24:
print mtime