版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a519395243/article/details/82014114
python3 用urllib时,出现http.client.IncompleteRead: IncompleteRead(34144 bytes read) 错误代码:
原出错代码:
html = urllib.request.urlopen(request).read().decode('utf-8')
解决方法:
try:
html = urllib.request.urlopen(request).read().decode('utf-8')
except Exception as e:
page = e.partial
html = page.decode('utf-8')
即 捕获异常, e.partial.decode('utf-8') 即可解决