Python fetches the key and the corresponding value of the dictionary in the list

has a list as follows

related codes

[
  {
    "id": 1,
    "title": "test",
    "content": "hello world    ",
    "author": "akirayu",
    "create_time": 1490161295
  },
  {
    "id": 2,
    "title": "testforgood ",
    "content": "you are not hired for skills you are hired for your motivate    ",
    "author": "akirayu102",
    "create_time": 1490161714
  }
]

I want to take key as "content" value as "you are not hired for skills you are hired for your motivate"

how can I get it through python? Thank you.

Jun.18,2021

list is assigned to the variable data. Use data [1] ['content'] to get what you want.


import json

s="""
[
  {
    "id": 1,
    "title": "test",
    "content": "hello world    ",
    "author": "akirayu",
    "create_time": 1490161295
  },
  {
    "id": 2,
    "title": "testforgood ",
    "content": "you are not hired for skills you are hired for your motivate    ",
    "author": "akirayu102",
    "create_time": 1490161714
  }
]
"""

js = json.loads(s)

print(js[1]["content"])
Menu