擅长:python、mysql、java
<blockquote>
<p>on the other hand, if I could just have the program load the X newest
files into the function, that would also work great.</p>
</blockquote>
<p>可以使用<a href="http://docs.python.org/2/library/os.path.html#os.path.getmtime" rel="nofollow noreferrer">^{<cd1>}</a>和<code>sorted</code>获取最近更改的文件列表:</p>
<pre><code>>>> import os
>>> sorted(filenames, key=lambda x:os.path.getmtime(x), reverse=True)[:5]
</code></pre>
<p>相关:<a href="https://stackoverflow.com/questions/237079/how-to-get-file-creation-modification-date-times-in-python">How to get file creation & modification date/times in Python?</a></p>