Python Cryptocompare API[错误]符号没有数据

Python Cryptocompare API[错误]符号没有数据,python,python-3.x,Python,Python 3.x,我正在使用Python,当我回忆起所有可用硬币的价格时,我经常会得到一个错误,我无法过滤[error],没有符号XXX的数据 代码如下: import requests import datetime import cryptocompare import datetime coin_list = cryptocompare.get_coin_list(format=False) date_today = datetime.datetime.now() for coin, data in coi

我正在使用Python,当我回忆起所有可用硬币的价格时,我经常会得到一个错误,我无法过滤[error],没有符号XXX的数据

代码如下:

import requests
import datetime
import cryptocompare
import datetime
coin_list = cryptocompare.get_coin_list(format=False)
date_today = datetime.datetime.now()
for coin, data in coin_list.items():
        nowprice = cryptocompare.get_historical_price(coin, 'USD', date_today)
        print (nowprice)
为什么我会犯这个错误?有办法避免吗? 如何过滤错误,使其不显示在屏幕上


谢谢

这是因为您使用的API 没有某些货币的历史信息,例如。除了忽略这些货币之外,你别无选择

您必须编辑cryptocompare.py并将query\u cryptocompare函数更改为:

def query_cryptocompare(url,errorCheck=True):
    try:
        response = requests.get(url).json()
    except Exception as e:
        print('Error getting coin information. %s' % str(e))
        return None
    if errorCheck and 'Response' in response.keys():
        if "There is no data for the symbol" not in response['Message']:
            print('[ERROR] %s' % response['Message'])
        return None
    return response

你能发布完整的回溯吗?@Farhan.K我尝试了以下方法:除了:用户代码中的打印异常:print'-'*60回溯。print\u excfile=sys.stdout print'-'*60,但是输出是非你不需要这样做。它应该显示回溯itself@Farhan.K它没有显示它,当出现错误时,唯一的输出是[error]符号$coin没有数据