我有以下內容的文本文件:如何從文本文件中將字符串轉換爲unicode?
Guadalajara
Culiacán
Juárez
Ecatepec
我想所有這些轉換爲Unicode。我試着使用:
unicode(INSERT WORD FROM TEXT FILE)
但我得到的錯誤:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 6: ordinal not in range(128)
反正從文本文件轉換字符串爲Unicode的?
嘗試使用'的Unicode(文字,「UTF-16」)' – Arman
對於這個解決方案,我得到了以下錯誤:UnicodeDecodeError錯誤:「UTF-16」編解碼器不能在14位解碼字節0X0A :截斷數據 – semiflex