Regular expression that finds and replaces non-ascii characters with Python

前端 未结 7 2211
無奈伤痛
無奈伤痛 2020-12-03 19:40

I need to change some characters that are not ASCII to \'_\'. For example,

Tannh‰user -> Tannh_user
  • If I use regular expression with Python, how
7条回答
  •  暖寄归人
    2020-12-03 20:14

    if you know which characters you want to replace, you can apply string methods

    mystring.replace('oldchar', 'newchar')
    

提交回复
热议问题