【发布时间】:2013-03-19 14:16:03
【问题描述】:
如何使用 python 将扩展 ASCII 字符如:“æ、ö 或 ç”转换为非扩展 ASCII 字符(a、o、c)?它的工作方式应该是,如果它以 "A, Æ ,Ä" 作为输入,它会为所有这些返回 A。
【问题讨论】:
标签: python type-conversion ascii extended-ascii
如何使用 python 将扩展 ASCII 字符如:“æ、ö 或 ç”转换为非扩展 ASCII 字符(a、o、c)?它的工作方式应该是,如果它以 "A, Æ ,Ä" 作为输入,它会为所有这些返回 A。
【问题讨论】:
标签: python type-conversion ascii extended-ascii
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'
【讨论】: