【问题标题】:Extended ASCII Character Conversion扩展 ASCII 字符转换
【发布时间】:2013-03-19 14:16:03
【问题描述】:

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

【问题讨论】:

    标签: python type-conversion ascii extended-ascii


    【解决方案1】:

    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'
    

    【讨论】:

    • 看起来不错,但在 python 2 中没有任何方法可以做到这一点吗?但是,如果没有,这将起作用。
    • 奇怪,我试过但没用。谢谢,我将使用 python 3 代码
    • 8 年后,我可以说这很老了 ;)
    猜你喜欢
    • 2012-11-18
    • 2012-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多