擅长:python、mysql、java
<p>这是@lenz的另一种解决方案。但我确实喜欢@lenz的建议<code>unidecode</code>更好=)</p>
<p>从
<a href="https://stackoverflow.com/questions/40872126/python-replace-non-ascii-character-in-string">Python - Replace non-ascii character in string (»)</a>和<a href="https://stackoverflow.com/questions/14682397/can-somone-explain-how-unicodedata-normalizeform-unistr-work-with-examples">Can somone explain how unicodedata.normalize(form, unistr) work with examples?</a></p>
<p>要解析元音变音符、重音和坟墓:</p>
<pre><code>>>> re.sub(r'[^\x00-\x7f]',r'', normalize('NFD', u"Avec Éloïse, ils président à l'assemblée"))
u"Avec Eloise, ils president a l'assemblee"
</code></pre>
<p>但它不能解决夏普-S字符和西里尔字母:</p>
^{pr2}$