Parsing JSON with Python: TypeError: list indices must be integers, not str

前端 未结 3 1972
执念已碎
执念已碎 2020-12-14 13:04

I\'m using Python to parse through some JSON data for specific values. Specifically I want to pull the following:

  • author_id
  • created_at
  • public
3条回答
  •  执念已碎
    2020-12-14 13:29

    print(fields['events'][0]['public'])
    

    fields['events'] is a list so you need to use ['events'][0] to access the dict inside the list.

提交回复
热议问题