我需要从Json响应中获得精确值
Json回复:
{
"data": {
"plot": "Rudy has always been told that he was too small to play college football. But he is determined to overcome the odds and fulfill his dream of playing for Notre Dame.",
"name": "Rudy",
"rating": "7.5",
"genre": "Biography,Drama,Sport",
"poster_url": "https://images-na.ssl-images-amazon.com/images/M/MV5BZGUzMDU1YmQtMzBkOS00MTNmLTg5ZDQtZjY5Njk4Njk2MmRlXkEyXkFqcGdeQXVyNjc1NTYyMjg@._V1_UY268_CR5,0,182,268_AL_.jpg"
}
}
Python代码:
response = requests.get(
"http://theapache64.xyz:8080/movie_db/search?keyword=Titanic")
json_data = json.loads(response.text)
print(json_data["plot"])
错误:
KeyError: 'plot'
我需要提取" plot"价值
答案 0 :(得分:2)
plot
位于data
内:
print(json_data['data']['plot'])