擅长:python、mysql、java
<p>您可以使用Python的<a href="https://docs.python.org/3/library/os.path.html" rel="nofollow noreferrer">^{<cd1>} module</a>-combine<a href="https://stackoverflow.com/questions/678236/how-to-get-the-filename-without-the-extension-from-a-path-in-python">^{<cd2>}</a>和{a3}的强大功能,而不是使用正则表达式:</p>
<pre><code>In [1]: import os
In [2]: filename = "/experimental/users/nerd/wavfiles/wavfile0722.wav"
In [3]: os.path.splitext(os.path.basename(filename))[0]
Out[3]: 'wavfile0722'
</code></pre>