我是编程和 python 的新手,所以请不要讨厌。我正在尝试构建一个程序,该程序将 Excel 表中的地址列表转换为列表,然后使用 google maps api 检索每个地址的距离和时间。到目前为止,我只能对一个地址进行硬编码。到目前为止,我唯一的问题是遍历 gmaps.directions() 参数。我很乐意帮助您如何做到这一点。所以最后我想要多次和距离来比较它们。谢谢
from googlemaps import GoogleMaps
import xlrd
gmaps = GoogleMaps('gmaps api')
wb = xlrd.open_workbook('addressbook.xlsx')
ws1 = wb.sheet_by_name('Sheet1')
ws2 = wb.sheet_by_name('Sheet2')
col1 = ws1.col_values(1)
col2 = ws2.col_values(1)
dirs = gmaps.directions(col1[0] ,col2[0])
time = dirs['Directions']['Duration']['seconds']
dist = dirs['Directions']['Distance']['meters']
print time
print dist