我试图用python写一些希伯来文本到.txt文件,但是看到希伯来语是非ascii和非utf -8我收到错误。我试图在文本文件中获取文本字符,而不是表示它。我的堆栈跟踪的如何写一个unicode字符到utf-8不支持的文件,python
hebrew_word = "שלום"
file = open("file_with_hebrew.txt", "w")
file.writelines(hebrew_word)
file.close()
部分:
UnicodeEncodeError: 'charmap' codec can't encode character '\u05e9' in position 0: character maps to <undefined>
“希伯来语非UTF-8”?呃,不行。这是完美的UTF-8。 – deceze