gad*_*lat 3 python exception-handling http
由于谷歌没有找到任何关于错误"http.client.HTTPException:得到超过100个标题",我创建了这个问题.
>>> import http.client as h
>>> conn = h.HTTPConnection("www.coursefinders.com")
>>> conn.request("HEAD","/")
>>> conn.getresponse();
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/http/client.py", line 1148, in getresponse
response.begin()
File "/usr/lib/python3.4/http/client.py", line 376, in begin
self.headers = self.msg = parse_headers(self.fp)
File "/usr/lib/python3.4/http/client.py", line 267, in parse_headers
raise HTTPException("got more than %d headers" % _MAXHEADERS)
http.client.HTTPException: got more than 100 headers
Run Code Online (Sandbox Code Playgroud)
这个异常是什么意思,我该如何正确处理这种类型的错误?网站在浏览器中正常运行
这是一个不涉及更改库的py文件的解决方案:
import httplib # or http.client if you're on Python 3
httplib._MAXHEADERS = 1000
Run Code Online (Sandbox Code Playgroud)
只需将它放在代码的顶部即可