擅长:python、mysql、java
<p>我自己也发现了类似的问题和解决办法。
<a href="https://stackoverflow.com/questions/4813061/nonalphanumeric-list-order-from-os-listdir-in-python">Nonalphanumeric list order from os.listdir() in Python</a></p>
<pre><code>import re
def sorted_alphanumeric(data):
convert = lambda text: int(text) if text.isdigit() else text.lower()
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
return sorted(data, key=alphanum_key, reverse=True)
</code></pre>