我想从这个 url 获取 api 信息: https : //api.binance.com/api/v1/ticker/24hr 我需要告诉一个符号 (ETHBTC) 并获取 lastprice。
import requests
binance = requests.get("https://api.binance.com/api/v1/ticker/24hr")
e = binance.json()
print(e['ETHBTC']['lastPrice'])
错误:
Traceback (most recent call last):
File "C:\Users\crist\Documents\Otros\Programacion\Python HP\borrar.py", line 6, in <module>
print(e['ETHBTC']['lastPrice'])
TypeError: list indices must be integers or slices, not str