【问题标题】:GeoPoint in Firestore using python使用 python 在 Firestore 中的 GeoPoint
【发布时间】:2019-03-01 00:50:23
【问题描述】:

我正在尝试使用 Python 将 GeoPoint 保存在我的 Firebase Firestore 中,但没有成功。 这给了我语法错误:

location=new firebase.firestore.GeoPoint(latitude, longitude)

有什么解决办法吗?也许我缺少要导入的东西,但我找不到什么。提前致谢。

【问题讨论】:

    标签: python python-3.x firebase google-cloud-firestore


    【解决方案1】:

    你可以使用

    from google.cloud.firestore import GeoPoint
    
    # Just example values so the code runs.
    latitude = 0.0
    longitude = 0.0
    location = GeoPoint(latitude, longitude)
    
    print(location)
    

    new不是python关键字,不需要使用。

    【讨论】:

    • 对于未来的访问者,您可以将 firestore 导入为from google.cloud import firestore,然后像location = firestore.GeoPoint(latitude, longitude) 一样操作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-07
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    • 2019-05-16
    • 1970-01-01
    相关资源
    最近更新 更多