扩展的ASCII字符转换

mad*_*mer 5 python ascii type-conversion extended-ascii

如何使用python 将扩展ASCII字符(如 "æ,ö或ç")转换为非扩展ASCII字符(a,o,c)?它的工作方式应该是,如果它以"A,Æ,Ä"作为输入,则返回所有它们的A.

小智 6

Unidecode可能对您有用.

Python 3.2.3 (default, Jun  8 2012, 05:36:09) 
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from unidecode import unidecode
>>> unidecode("æ, ö or ç")
'ae, o or c'
Run Code Online (Sandbox Code Playgroud)