如何从请求中解析python列表类型
我想使用比特币api。收到的数据如下:如何从请求中解析python列表类型,python,Python,我想使用比特币api。收到的数据如下: [ { 'market': 'KRW-BTC', 'candle_date_time_utc': '2020-05-04T03:17:00', 'candle_date_time_kst': '2020-05-04T12:17:00', 'opening_price': 10662000.0, 'high_price': 10676000.0, 'low_price': 10662000.0, '
[
{
'market': 'KRW-BTC',
'candle_date_time_utc': '2020-05-04T03:17:00',
'candle_date_time_kst': '2020-05-04T12:17:00',
'opening_price': 10662000.0,
'high_price': 10676000.0,
'low_price': 10662000.0,
'trade_price': 10675000.0,
'timestamp': 1588562256134,
'candle_acc_trade_price': 18269778.31894,
'candle_acc_trade_volume': 1.71334319,
'unit': 1
}
]
这只是一个列表类型数据
我想在下面分析这些数据:
['market':“KRW-BTC”,'candle\u date\u time\u utc':'2020-05-04T03:17:00'~~]
如何执行此操作?这是如何访问字典列表中的值
r = [{'market': 'KRW-BTC', 'candle_date_time_utc': '2020-05-04T03:17:00', 'candle_date_time_kst': '2020-05-04T12:17:00', 'opening_price': 10662000.0, 'high_price': 10676000.0, 'low_price': 10662000.0, 'trade_price': 10675000.0, 'timestamp': 1588562256134, 'candle_acc_trade_price': 18269778.31894, 'candle_acc_trade_volume': 1.71334319, 'unit': 1}]
# r < this is the list [0] < the index of the dictionary in the list 'market' the key to the value you'd like to extract
print (r[0]['market'])
print (r[0]['candle_date_time_utc'])
r=[{'market':'KRW-BTC','candle_date_time_utc':'2020-05-04T03:17:00','candle_date_time_kst':'2020-05-04T12:17:00','opening_price':10662000.0,'low_price':10662000.0,'trade_price':10675000.0,'timestamp':158562256134,'candler(candle((ơ)((acc)交易价格:'acc交易量:18269778.31894,'candle))()
#r<这是列表[0]<列表“market”中字典的索引您要提取的值的键
打印(r[0][“市场])
打印(r[0]['candle\u date\u time\u utc'])
您可以迭代列表
list =[{'market': 'KRW-BTC', 'candle_date_time_utc': '2020-05-04T03:17:00', 'candle_date_time_kst': '2020-05-04T12:17:00', 'opening_price': 10662000.0, 'high_price': 10676000.0, 'low_price': 10662000.0, 'trade_price': 10675000.0, 'timestamp': 1588562256134, 'candle_acc_trade_price': 18269778.31894, 'candle_acc_trade_volume': 1.71334319, 'unit': 1}]
for obj in list:
print(obj['market'])
解析是什么意思?您想访问market和candle_date_time_utc中的值吗?这是作为字符串返回的还是作为上述词典列表返回的?到目前为止您是否尝试过任何操作?您可以共享代码吗?您想要作为结果的列表无效。
{market':'KRW-BTC','candle_date_time':'2020-05-04',}
is。您的意思是要从收到的列表中提取词典吗?您尝试了什么?您的代码在哪里?