python 连接数据库winerror 10054_Python 3,Windows 7:ConnectionResetError:[WinError 10054]远程主机强制关闭现有连接...

编辑:

我使用企业环境,在我家的环境上,脚本工作正常

我想从一些天气网站得到回应.我制作了一个简单的python脚本.

import urllib.request

import json

req=urllib.request.Request("http://api.wunderground.com/api/e0b319c6f7e8115a/geolookup/conditions/q/IA/Cedar_Rapids.json")

response=urllib.request.urlopen(req)

data = json.loads(response.read().decode()) #

print (data)

当我将URL粘贴到浏览器中时,我得到了响应,但是在python中我得到了错误

请帮忙

完全错误

Traceback (most recent call last):

File "C:\Python34\weather.py", line 14, in

response=urllib.request.urlopen(req)

File "C:\Python34\lib\urllib\request.py", line 153, in urlopen

return opener.open(url, data, timeout)

File "C:\Python34\lib\urllib\request.py", line 455, in open

response = self._open(req, data)

File "C:\Python34\lib\urllib\request.py", line 473, in _open

'_open', req)

File "C:\Python34\lib\urllib\request.py", line 433, in _call_chain

result = func(*args)

File "C:\Python34\lib\urllib\request.py", line 1202, in http_open

return self.do_open(http.client.HTTPConnection, req)

File "C:\Python34\lib\urllib\request.py", line 1177, in do_open

r = h.getresponse()

File "C:\Python34\lib\http\client.py", line 1172, in getresponse

response.begin()

File "C:\Python34\lib\http\client.py", line 351, in begin

version, status, reason = self._read_status()

File "C:\Python34\lib\http\client.py", line 313, in _read_status

line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")

File "C:\Python34\lib\socket.py", line 371, in readinto

return self._sock.recv_into(b)

ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值