【发布时间】:2011-09-26 08:13:33
【问题描述】:
我正在使用 file.readline() 读取包含 Python 中罗马尼亚语单词的文件。 由于编码,我遇到了很多字符的问题。
例子:
>>> a = "aberație" #type 'str'
>>> a -> 'abera\xc8\x9bie'
>>> print sys.stdin.encoding
UTF-8
我已经尝试使用 utf-8、cp500 等进行 encode(),但它不起作用。
我找不到我必须使用的正确字符编码?
提前致谢。
编辑:目的是将文件中的单词存储在字典中,并在打印时获取 aberație 而不是 'abera\xc8\x9bie'
【问题讨论】:
标签: python file encoding decoding representation