我正在尝试使用python从API提取数据。通过此代码,我试图在列表中打印字典的内容。
response = requests.get(url, params=payload)
data = response.json()
log = json.dumps(data['result'], indent = 1)
print log
到目前为止,它可以打印:
[
{
"line": "[email protected]:birthdaydate"
},
{
"line": "[email protected]:birthdaydate"
},
{
"line": "[email protected]:birthdaydate"
},
]
有没有一种方法可以使输出看起来像下面的样子?
"[email protected]:birthdaydate"
"[email protected]:birthdaydate"
"[email protected]:birthdaydate"
尝试这个:
response = requests.get(url, params=payload)
data = response.json()
log = data['result']
for l in log:
print(l["line"])