Friday, 15 May 2015

utf 8 - Python - Change string to utf8 -


I am trying to write Portuguese in an HTML file but I'm getting some strange characters. ?

  ago = "" "& lt; p style =" color: red; Font-Family: 'Liberation Sons', Non-Serif "& gt; {} & lt; / p & gt;" Expected output: May be any one of the POs ...  

Browser (Sentence 1 [i]) f.write (first)

Expected output: In real output (Firefox on Ubuntu): I »¿Hodge, Nos No Animos Ao PO ...

I tried to do this:

  ago =" " "& Lt; P style = "color: red; font-family: 'Liberation suns', non-serif" & gt; {} & Lt; / P & gt; "". Format (Sentence 1 [i]) f.write (first.encode ('utf8'))  Output in terminal: Unicodecode error: 'ASCI' can not decode byte codex of 65 'codec: in serial number No (128) 

Why am I getting this error and how can I write other languages ​​in an HTML document without weird characters?
Or, is there a different file type that I can write with the above font formatting?

Your format string should also be a unicode string:

  before = U "" "& lt; p style =" color: red; Font-Family: 'Liberation Sons', Non-Serif' & gt; {} & Lt; / P & gt; "". Format (sentence 1 [i]) f.write (first)  

No comments:

Post a Comment