擅长:python、mysql、java
<pre><code>import glob
used_filenames = {name:True for name in glob.glob('foo.[0-9][0-9][0-9]'))}
for i in range(1000):
prospect = "foo.{:03d}".format(i)
if prospect not in used_filenames:
print("The next unused filename is", prospect)
break
</code></pre>