我试着阅读我的Python项目的WWW站点。但是,如果我无法连接到互联网,代码就会崩溃。如果在读取站点的某个点没有连接,如何捕获异常?
import sys
import time
import urllib3
# Gets the weather from foreca.fi.
def get_weather(url):
http = urllib3.PoolManager()
r = http.request('GET', url)
return (r.data)
time = time.strftime("%Y%m%d")
ur
运行错误:
qcloud_cos.cos_exception.CosClientError: HTTPConnectionPool(host='127.0.0.1', port=42981): Max retries exceeded with url: http://360cities-1255810466.cos.ap-chengdu.myqcloud.com/workspace/angler/bianshow/720yun/panotmp/preview.jpg (Caused by ProxyError('Cannot connect to proxy.'
免责声明:我是Python的新手,这可能是一个愚蠢的问题,也可能是一个非常严重的问题。我不知道该期待什么。
我用python编辑了一个交易机器人,一切都很好,但有时,可能是由于互联网连接不好,我得到了一个错误,python应用程序关闭了自己。
错误是这个(我要给出*合理的数据)
File "runeth.py", line 217, in <module>
p = s.my_position(symbol=configeth.SYMBOL)['result']
File "/home/mosf/.local/lib/python3
我正在使用Python向smashgg API请求内容(查询是用GraphQL编写的),在运行下面的代码时,我得到了一个以前从未遇到过的错误: headers = {"Authorization": "Bearer my token"}
def run_query(query, variables): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://a
我正在使用urllib2.urlopen循环调用Python中的URL
我的URL每次都在更改(因为URL的特定参数每次都有更改)。
我的代码如下所示:
def get_url(url):
'''Get json page data using a specified API url'''
response = urlopen(url)
data = str(response.read().decode('utf-8'))
page = json.loads(data)
return pag