我似乎无法读取 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 等于“记录的用户名”用户名的密码
<firebase_admin.db.Reference object at 0x103a7d190>
不是错误,它实际上是没有字符串表示的对象的打印。这说明内存地址 firebase_admin.db.Reference
处有一个
0x103a7d190
对象。
尝试使用以下方式打印:
print(check_password.get())