6
我一直在努力與這一段時間。我正在嘗試將字符串寫入HTML,但一旦我清除了它們,就會遇到格式問題。這裏有一個例子:Python的HTML編碼 xc2 xa0
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空白字符? –