Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的 JSON
{"sites":[{"site_id":1234,..,..}, {"site_id":5678,..,..}]}
我正在尝试使用以下方法遍历它:
for site_id in account['sites']['site_id']: print(site_id)
产生:
list indices must be integers, not str
account['sites']是一个字典列表,遍历它并site_id按键获取值:
account['sites']
site_id
for site in account['sites']: print site['site_id']