|
发表于 2015-12-22 13:14:45
|
显示全部楼层
本帖最后由 kathy_lockhart 于 2015-12-22 13:56 编辑
请问我使用mac版python,打开一个txt文件后,再用read会报错,例如:
e=open('/Users/tiantianfeng/Documents/python20151222.txt')
e.read()
此时提示:
Traceback (most recent call last):
File "<pyshell#48>", line 1, in <module>
e.read()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 26: ordinal not in range(128)
这要如何解决呢?
我把汉字部分都去掉就没事了,是汉字的问题嘛?还是汉字中标点符号的问题? |
|