[英]api problems getting nested queries in python
I'm writing a script in python and am accessing an API. 我正在用python编写脚本并正在访问API。 I can get some information I need but where I'm stuck is with nested queries. 我可以获得一些我需要的信息,但是我遇到的问题是嵌套查询。 In my code below, first_name needs to equal what would essentially be result[customer->firstname] but I cannot figure out how to get that. 在下面的代码中,first_name需要等于本质上为result [customer-> firstname]的值,但是我不知道如何获得它。
What is the proper syntax to get a nested query like that? 获得这样的嵌套查询的正确语法是什么?
Orders-> customer -> firstname
for result in results['orders']:
order_status_info= self_api.which_api('order_statuses/%d' % result['order_status_id'])
for customer_blocked_reason in customer_blocked_reasons:
if customer_blocked_reason in order_status_info['name']:
customer_is_blocked = True
order_id = 0
order_date = result['ordered_at']
first_name = result [??????]
Is result a dict? 结果是命令吗?
You can access nested dictionaries like so: 您可以像这样访问嵌套字典:
>>> d = {"level1": {"level2": "somedata"}}
>>> d["level1"]["level2"]
'somedata'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.