我想了解utf-8 ascii和unicode之間的區別。我已經讀過這Unicode, UTF, ASCII, ANSI format differences。 但我得到一些錯誤@python,我不知道我怎麼能看到我的字符串有哪種格式。Utf-8 - ascii - unicode - 例子[Python]
例如:由於 'U'
1# 'Klaus-Groth-Straße, Ballahausen'
2# 'Capit\xe1n\n'
3# u'Capit\xe1n\n'
3#= unicode的?
1#=?
2#=?
我已經tryed寫串1#到一個文件,寫了自己的一個小功能
def escape(html):
html=html.replace('ö','ö')
html=html.replace('Ö','Ö')
html=html.replace('ä','ä')
html=html.replace('Ä','Ä')
html=html.replace('ü','ü')
html=html.replace('Ü','Ü')
html=html.replace('ß','ß')
return html
之前,我該怎麼寫我的字符串到一個txt文件,我會代替字母來獲得在我的txt文件(克勞斯 - 格羅斯,STRA ß E,諾爾登堤岸布赫霍爾茨)
但它不工作的權利拼寫:/
你能告訴我哪一種米y 3個例子屬於unicode/ascii/utf8?和我怎樣寫正確的拼寫一個txt使用字符串像1#
Tyvm
[如何停止的痛苦?(http://nedbatchelder.com/text/unipain.html) –
再舉例來說,#1,看http://stackoverflow.com/questions/1208916/decoding-html -entities-with-python –