【发布时间】:2015-12-01 21:07:47
【问题描述】:
我已经为此苦苦挣扎了一段时间。我正在尝试将字符串写入 HTML,但是一旦我清理了它们,格式就会出现问题。这是一个例子:
paragraphs = ['Grocery giant and household name Woolworths is battered and bruised. ',
'But behind the problems are still the makings of a formidable company']
x = str(" ")
for item in paragraphs:
x = x + str(item)
x
输出:
"Grocery giant and household name\xc2\xa0Woolworths is battered and\xc2\xa0bruised.
But behind the problems are still the makings of a formidable\xc2\xa0company"
期望的输出:
"Grocery giant and household name Woolworths is battered and bruised.
But behind the problems are still the makings of a formidable company"
我希望您能够解释为什么会发生这种情况以及我该如何解决。提前致谢!
【问题讨论】:
-
您是否检查过源字符串中的异常 Unicode 空白?