Firebase 无法读取,有什么办法解决这个问题吗?

问题描述 投票:0回答:1

我似乎无法读取 db.reference('credentials/login/' +logging_username) 因为当我打印它时它给了我这个错误:.

这是我的代码:

import firebase_admin
from firebase_admin import credentials
from firebase_admin import db

cred = credentials.Certificate('ServKey.json')

logged = input("are you logged in (True / False)")

firebase_admin.initialize_app(cred, {
    'databaseURL' : 'https://chatat-73f4a-default-rtdb.europe-west1.firebasedatabase.app/'
})

ref = db.reference('credentials/')



if logged == "False" :
    register_username = input("What do you want your username to be ? ")
    register_password = input("What do you want your password to be ? ")



login_ref = ref.child('login')
def setlogin() : 
    login_ref.set({
    register_username : {
    'Password' : register_password,     
    }
    })

if logged == "False":    
    setlogin()
    print("ouisir")
      
if logged == "True" :
    logged_username = input("What is your username ? ")
    logged_password = input("What is your password ? ")
    check_password = db.reference('credentials/login/' + logged_username)
    
if check_password == logged_password :
        logged_in = True

print(check_password)

我期望 check_password 等于“记录的用户名”用户名的密码

python database firebase firebase-realtime-database firebase-authentication
1个回答
0
投票

<firebase_admin.db.Reference object at 0x103a7d190>
不是错误,它实际上是没有字符串表示的对象的打印。这说明内存地址 firebase_admin.db.Reference
 处有一个 
0x103a7d190
 对象。

尝试使用以下方式打印:

print(check_password.get())
© www.soinside.com 2019 - 2024. All rights reserved.