使用conn = httplib.HTTPConnection(" http:// ipaddr:port")时出错 [英] Error while using conn = httplib.HTTPConnection ("http://ipaddr:port")

查看:257
本文介绍了使用conn = httplib.HTTPConnection(" http:// ipaddr:port")时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

httplib.HTTPConnection ("http://ipaddr:port")  
conn.request("GET", "", params, headers)

我可以做PUT / GET使用ipaddr:使用我的firefox客户端端口!!
但我在执行脚本时看到这个错误:

I am able to do PUT/GET using ipaddr:port using my firefox client!!. But I am seeing this error on execution of the script:

 File "post_python.py", line 5, in <module>
    conn.request("GET", "", params, headers)
  File "/usr/lib64/python2.6/httplib.py", line 914, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python2.6/httplib.py", line 951, in _send_request
    self.endheaders()
  File "/usr/lib64/python2.6/httplib.py", line 908, in endheaders
    self._send_output()
  File "/usr/lib64/python2.6/httplib.py", line 780, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.6/httplib.py", line 739, in send
    self.connect()
  File "/usr/lib64/python2.6/httplib.py", line 720, in connect
    self.timeout)
  File "/usr/lib64/python2.6/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known"

请有人帮助我吗?

推荐答案

试试这个(没有http:// 在IP地址之前:

Try this instead (without "http://" before the IP address):

conn = httplib.HTTPConnection("x.x.x.x", port)  
conn.request("GET", "", params, headers)

这篇关于使用conn = httplib.HTTPConnection(&quot; http:// ipaddr:port&quot;)时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆