|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
第28讲的课后作业,我下载了,用文本编辑器打开没问题,在Python中打开报错,好像是编码格式的问题,详见附件,谁遇到过这种问题,能否解答一下Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> f=open('/Volumes/air2/OpenMe.mp3','r')
>>> f.read()
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
f.read()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte
>>> f.read()
''
>>> f.readline()
''
>>>
open语句这样写:
- f = open("文件路径", 'r', encoding = 'gbk')
复制代码
|
|