小编don*_*ame的帖子

使用Python从字符串中删除不间断的空格

我在Python中遇到一个非常基本的字符串问题(我无法弄清楚).基本上,我正在尝试执行以下操作:

'# read file into a string 
myString =  file.read()

'# Attempt to remove non breaking spaces 
myString = myString.replace("\u00A0"," ")

'# however, when I print my string to output to console, I get: 
Foo **<C2><A0>** Bar
Run Code Online (Sandbox Code Playgroud)

我认为"\ u00A0"是unicode非破坏空间的转义码,但显然我没有正确地做到这一点.关于我做错了什么的任何想法?

python string unicode text

26
推荐指数
5
解决办法
3万
查看次数

标签 统计

python ×1

string ×1

text ×1

unicode ×1