Python Codage HTML \xc2\xa0

J'ai eu du mal avec celui-ci pendant un certain temps. Je suis en train d'écrire des chaînes de caractères au format HTML, mais ont des problèmes avec le format une fois que j'ai nettoyé. Voici un exemple:

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

De sortie:

"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"

De sortie souhaité:

"Grocery giant and household name Woolworths is battered and bruised. 
But behind the problems are still the makings of a formidable company"

J'espère que vous êtes en mesure d'expliquer pourquoi cela se produit et comment je peux résoudre. Merci à l'avance!

  • Avez-vous vérifié pour des espaces Unicode dans la chaîne source?
InformationsquelleAutor Sam Perry | 2015-09-06