【发布时间】:2017-11-06 01:22:45
【问题描述】:
我正在检查 Google API 响应:
url = 'https://maps.googleapis.com/maps/api/place/textsearch/json?'
params = {'location': '-38.30000000,176.15000000',
'radius': '5000',
'type': 'movie_theater',
'key': 'MY_KEY'}
response = requests.get(url = url, params=params)
# if response.status_code == 200:
response_data = response.json()
if 'results' in response_data:
print ('There are results')
elif response_data['status'] == 'ZERO_RESULTS':
print ('nothing')
如果您使用 Postman 搜索该特定位置:
https://maps.googleapis.com/maps/api/place/textsearch/json?location=-38.30000000,176.15000000&radius=5000&type=movie_theater&key=MY_KEY
没有电影院和 Google API 报告:
{
"html_attributions": [],
"results": [],
"status": "ZERO_RESULTS"
}
不幸的是,我的if、elif 似乎无法正常工作,因为它无法打印nothing。
我哪里错了?
【问题讨论】:
标签: python json google-maps postman