【问题标题】:Syntax error when using google module maps使用谷歌模块地图时的语法错误
【发布时间】:2019-11-14 13:33:59
【问题描述】:

我正在编写代码,我需要一个特定的时区,我使用谷歌地图库,我从 github 复制了代码,但它仍然报错。我正在使用 Python 3.7

我第一次使用这个库。

import googlemaps
from datetime import datetime

gmaps = googlemaps.Client(key=('Here my API')
# Geocoding an address

geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')


# Request directions via public transit
now = datetime.now()
directions_result = gmaps.directions("Sydney Town Hall",
                                     "Parramatta, NSW",
                                     mode="transit",
                                     departure_time=now)

错误: 第 7 行 geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain 查看,CA') SyntaxError: 无效语法

【问题讨论】:

  • 你下载的git文件还是导入的?

标签: python syntax-error


【解决方案1】:

您不要关闭上面的( ) 行:

看那里:

gmaps = googlemaps.Client(key=('Here my API')

它看起来应该是封闭的:

gmaps = googlemaps.Client(key=('Here my API'))

每次在语法上,都没有 lib 的原因

【讨论】:

  • XD 非常感谢!
猜你喜欢
  • 2013-07-05
  • 1970-01-01
  • 2016-05-09
  • 2020-12-06
  • 1970-01-01
  • 1970-01-01
  • 2016-06-15
相关资源
最近更新 更多