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') 即可解决