首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将非ascii字符转换为ascii字符

将非ascii字符转换为ascii字符
EN

Stack Overflow用户
提问于 2021-04-20 18:00:02
回答 1查看 137关注 0票数 3

我正在寻找转换这个字符串:

代码语言:javascript
复制
test = "Il était toujours temps d’étouffer l’inflation par la hausse des taux"

要这样做:

代码语言:javascript
复制
test = "Il était toujours temps d'étouffer l'inflation par la hausse des taux"

我的意思是将非ascii字符替换为“真正的”单词/字母。

EN

回答 1

Stack Overflow用户

发布于 2021-04-20 18:35:55

代码语言:javascript
复制
test.encode('cp1252').decode('utf-8')

我已经试过了,它很管用。我从here那里拿的

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67176671

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档