简体   繁体   中英

Convert non-ascii character to ascii character

I'm looking for convert this string:

test = "Il était toujours temps d’étouffer l’inflation par la hausse des taux"

to this:

test = "Il était toujours temps d'étouffer l'inflation par la hausse des taux"

I mean replace the non ascii character by "real" words/letters.

test.encode('cp1252').decode('utf-8')

I've tried this and it works. I took it from here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM