028课后作业我无法在jupyter notebook完成这个操作
f = open('OpenMe.mp3')for each_line in f:
print(each_line,end='')
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
for each_line in f:
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 open("tst.txt", "r", encoding ='utf-8') 试试看:
f = open('OpenMe.mp3','rb')
for each_line in f:
print(each_line,end='') 试试:
f = open('OpenMe.mp3',encoding='cp936')
或者:
f = open('OpenMe.mp3',encoding='ansi') f = open('OpenMe.mp3', encoding="utf-8")
for each_line in f:
print(each_line,end='')
参考:https://fishc.com.cn/thread-158932-1-1.html 不认识的错误代码,粘下来百度。
你这个是编码错误,
- 小甲鱼的Python 标准异常总结[https://fishc.com.cn/thread-45814-1-1.html]
- 小甲鱼也有关于编码问题和文件打开方法的帖子,想看自己搜索一下吧。 txxcat 发表于 2020-4-5 00:08
试试:
或者:
都好像没有这个 zltzlt 发表于 2020-4-5 08:13
参考:https://fishc.com.cn/thread-158932-1-1.html
可不行还是打不开的 ba21 发表于 2020-4-4 23:48
open("tst.txt", "r", encoding ='utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte
不行还是这个报错 xiangjianshinan 发表于 2020-4-4 23:56
试试看:
f = open('OpenMe.mp3','rb')
可这个打开是2进制不是汉字啊 会计的会怎么念 发表于 2020-4-5 10:58
不认识的错误代码,粘下来百度。
你这个是编码错误,
- 小甲鱼的Python 标准异常总结
好我会去查查 郭书宇 发表于 2020-4-10 14:21
都好像没有这个
有什么错误提示?
页:
[1]