【问题标题】:Accessing firebase object with python and get 'DatetimeWithNanoseconds' object has no attribute 'ToDatetime'使用python访问firebase对象并获取'DatetimeWithNanoseconds'对象没有属性'ToDatetime'
【发布时间】:2021-03-17 16:28:28
【问题描述】:

我正在编写一个简单的云函数来查找 firebase 中的新对象。我正在使用以下功能;

def users_and_tours(event, context):
    today = datetime.now()
    query_tours = db.collection('tours')
    query_users = db.collection('users')


    #avg_num_signed_up_per_day
    emails = {}
    for doc in query_users.stream():
        created_date = doc.create_time.ToDatetime()
        since_creation = (today - created_date).days

这个可以正常使用,我没有更改云功能,但现在出现此错误 第 31 行,在 users_and_tours created_date = doc.create_time.ToDatetime() AttributeError: 'DatetimeWithNanoseconds' object has no attribute 'ToDatetime''

有谁知道如何解决这个问题?谢谢

【问题讨论】:

    标签: python firebase google-cloud-platform google-cloud-functions


    【解决方案1】:

    如果你的函数代码没有改变,你应该看看云函数访问的内容。

    我对@9​​87654321@ 的理解是neverToDatetime

    您能否指出您的requirements.txt 以及对象user 在Firestore 控制台中的屏幕截图?

    【讨论】:

      猜你喜欢
      • 2013-08-13
      • 2013-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-05
      相关资源
      最近更新 更多