擅长:python、mysql、java
<p>下面将为您提供当前目录树下的文件列表,并带有指定的后缀。你知道吗</p>
<pre><code>from pathlib import Path
filelist = list( Path( '.' ).glob('**/*.kfm') )
print( filelist )
</code></pre>
<p>在下面,我们更进一步。我们对文件列表进行排序,然后对文件进行循环</p>
<pre><code>from pathlib import Path
mysubdir = 'whatever'
pathlist = Path( mysubdir).glob('**/*.kfm')
filelist = sorted( [str(file) for file in pathlist] )
for file in filelist:
print( file )
</code></pre>