【发布时间】:2021-11-04 16:23:41
【问题描述】:
我不明白我做错了什么。我的 API 已启用。
这是我的代码:
# importing required libraries
import requests, json
# enter your api key here
api_key = 'API KEY'
# Take source as input
source = 'h4n1g1'
# Take destination as input
dest = 'h4n1p8'
# url variable store url
url = 'https://maps.googleapis.com/maps/api/distancematrix/json?'
# Get method of requests module
# return response object
r = requests.get(url + 'origins = ' + source +
'&destinations = ' + dest +
'&key = ' + api_key)
# json method of response object
# return json format result
x = r.json()
# by default driving mode considered
# print the value of x
print(x)
Google 距离 API 工作正常,但矩阵 API 不行。
【问题讨论】:
标签: python google-api