公共API用JSON回复我,它具有下一种格式
{"ABCD-EFG":
{"param1":"0.1234",
"param2":"0.123456",
"param3":"0.12334254"},
"HIG-KLMN":
{"param1":"0.3456",
"param2":"0.05710"
"param3":"0.004903"
... }
如何使用Python3获取名称列表(在此考试ABCD-EFG,HIG-KLMN中)?
他们可以在每次发送API请求时对其进行更改
如果它像'名字':'ABCD-EFG',那将很容易。但它不是那样的。
答案 0 :(得分:-1)
有几种方法,一种是:
x = {
"ABCD-EFG": {
"param1":"0.1234",
"param2":"0.123456",
"param3":"0.12334254"
},
"HIG-KLMN": {
"param1":"0.3456",
"param2":"0.05710",
"param3":"0.004903"
}
}
y = list(x.keys())
print(y)
for key in x.keys():
print(key)
给出:
['ABCD-EFG', 'HIG-KLMN']
ABCD-EFG
HIG-KLMN