我試圖用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