【发布时间】:2017-07-09 12:17:15
【问题描述】:
我需要从 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'
我需要提取“情节”值
【问题讨论】:
标签: json python-3.x api get request