Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Coinbase API返回“;讯息;但没有实际的信息_Python_Coinbase Api_Cryptocurrency - Fatal编程技术网

Python Coinbase API返回“;讯息;但没有实际的信息

Python Coinbase API返回“;讯息;但没有实际的信息,python,coinbase-api,cryptocurrency,Python,Coinbase Api,Cryptocurrency,使用danpaquin的cbpro包,然后调用“auth_client.get_fills”方法来请求特定产品Coinbase提供的所有订单填充。例如: all_fills = {} for product in products: all_fills[product] = [] fills = a.get_fills(product) for fill in fills: for x,y in fill.items(): prin

使用danpaquin的cbpro包,然后调用“auth_client.get_fills”方法来请求特定产品Coinbase提供的所有订单填充。例如:

all_fills = {}
for product in products:
    all_fills[product] = []
    fills = a.get_fills(product)
    for fill in fills:
        for x,y in fill.items():
            print(f"\t{x}: {y}")
        print(fill)
        all_fills[product].append(fill)
    print(f"{product} captured.")
作为参考,我计划中的“产品”是Coinbase提供的所有硬币配对的列表。“ETH-USD”、“LTC-USD”等

.get_fills()返回该特定产品的所有订单填充的生成器

我这里的问题是,在某些产品上,生成器(fills)返回的迭代(fill)实际上就是字符串“message”。根据我上面的代码,这自然会产生一个错误

AttributeError: 'str' object has no attribute 'items'
我从Coinbase文档中了解到,错误以json的形式返回,其中“消息”是关键之一

如果这实际上只是某种错误消息、完成消息或其他任何消息的密钥。。。我希望能够看到消息的实际内容,而不仅仅是字符串“message”。有人知道我错过了什么吗

我从Coinbase文档中了解到,错误以json的形式返回,其中“消息”是关键之一

对!根据Coinbase官方文档(请参阅),出现错误的调用将输出以下内容:

{
"message": "Invalid Price"
}
,因此是JSON或字典格式-无论您想以何种方式解码它。 在这种情况下,您可以通过
dictionary\u name['message']
检索错误消息的值

另一种可能是使用json标准库()并通过
json.dumps(dictionary\u name)
转储整个字典本身