gpt4 book ai didi

python - 扩展 ASCII 字符转换

转载 作者:太空狗 更新时间:2023-10-30 01:02:31 25 4
gpt4 key购买 nike

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

最佳答案

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 - 扩展 ASCII 字符转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15693756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com