您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

为什么在python中出现此错误?(httplib)

为什么在python中出现此错误?(httplib)

httplib(Python 2)的文档在Python 3中称为http.client)中:

例外 httplib. :( 例外 http.client. :)

的子类HTTPException

在服务器响应我们不理解的HTTP状态代码时引发。

我运行了相同的代码,但未收到错误

>>> theurl = 'http://www.garageband.com/mp3cat/.UZCKbS6N4qk/01_Saraenglish.mp3'
>>> if theurl.startswith("http://"):
...     theurl = theurl[7:]
...     head = theurl[:theurl.find('/')]
...     tail = theurl[theurl.find('/'):]
... 
>>> head
'www.garageband.com'
>>> tail
'/mp3cat/.UZCKbS6N4qk/01_Saraenglish.mp3'
>>> response_code = 0
>>> import httplib
>>> conn = httplib.httpconnection(head)
>>> conn.request("HEAD", tail)
>>> res = conn.getresponse()
>>> res.status
302
>>> response_code = int(res.status)

我想只是仔细检查所有内容,然后重试?

python 2022/1/1 18:48:03 有561人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶