Firestore文档快照到Python字典

Firestore文档快照到Python字典,python,google-cloud-firestore,Python,Google Cloud Firestore,嗨,我一直在兜圈子,试图把我的Firestore数据放到Python 2字典中 doc_ref = db.collection('things1').document('ref1').collection('things2').document('ref2') doc = doc_ref.get() 给我一个文档快照-我希望得到一个dict。根据结果创建dict的正确方法是什么。尝试了文档,最终得到了对象。我正在(不)做的蠢事 谢谢您可以使用。这会给你结果的字典 doc_ref

嗨,我一直在兜圈子,试图把我的Firestore数据放到Python 2字典中

    doc_ref = db.collection('things1').document('ref1').collection('things2').document('ref2')
    doc = doc_ref.get()
给我一个文档快照-我希望得到一个dict。根据结果创建dict的正确方法是什么。尝试了文档,最终得到了对象。我正在(不)做的蠢事

谢谢

您可以使用。这会给你结果的字典

doc_ref = db.collection('things1').document('ref1').collection('things2').document('ref2') 
doc = doc_ref.get().to_dict()
你可以用。这会给你结果的字典

doc_ref = db.collection('things1').document('ref1').collection('things2').document('ref2') 
doc = doc_ref.get().to_dict()
这对我有用

doc = {el.id: el.to_dict() for el in doc_ref}
这对我有用

doc = {el.id: el.to_dict() for el in doc_ref}

为什么这突然不是正确的答案@镇上的男孩?为什么这突然不是正确的答案@镇长?