擅长:python、mysql、java
<p>即使递归地调用函数<code>func</code>,第一次迭代中的<code>f</code>也不会更改,<code>fnmatch</code>只检查字符串,如果文件存在,则不检查。在</p>
<p>使用<code>os.path.exists</code>:
导入操作系统,fnmatch,时间</p>
<pre><code>def func(filenames):
for f in filenames:
if fnmatch.fnmatch(f, '*.part'):
# wait until deleted
while os.path.exists(f):
time.sleep(0.1)
</code></pre>