擅长:python、mysql、java
<p>使用以下正则表达式可以获得每个文件的编号:</p>
<pre><code>import re
for file in list_of_files:
num = int(re.search('file(\d*)', file).group(1)) # assuming filename is "filexxx.txt"
# compare num to previous max, e.g.
max = num if num > max else max # set max = 0 before for-loop
</code></pre>
<p>在循环的末尾,max将是您的最高文件名编号。在</p>