学习一哈哈
utf-8经常不好使
牛逼
被bytes和string搞的有点生活不能自理了。。
看看
谢楼主分享
很好
看内容
群已经满了
O(∩_∩)O谢谢分享啊
还是不知道啥时候用encode,啥时候用decode呢
给力,好好瞧瞧,希望能解决问题
学习了,谢谢楼主
还没学到使用urllib。先看看方法
很有用的帖子
学习ing
本帖最后由 小小D调 于 2017-2-6 11:35 编辑
我按照上面的修改,仍然不行
>>>f=open('D:\\长恨歌.txt',encoding='utf8')
>>> f.read()
Traceback (most recent call last):
File "<pyshell#351>", line 1, in <module>
f.read()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 30: invalid start byte
好,很好
谢谢楼主的分享!
import urllib.request
url='http://www.whatismyip.com.tw'
proxy_support=urllib.request.ProxyHandler({'http':'218.75.100.114'})
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)
response = urllib.request.urlopen(url)
html = response.read().decode('utf-8')
print(html)
错误:
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/python 练习2.0/proxy.py", line 12, in <module>
html = response.read().decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb7 in position 209: invalid start byte
55课视频教学中发生如下错误,不理解,请教楼主