你好,我使用python与firebase,但我无法正确执行下面的代码。我想'data.Child('move').get()'去只为值,但当我运行的程序给我以下'Ordereddict([('move', True)]),我想你给我只有真。
import pyrebase
config = {
"apiKey": "...",
"authDomain": "...",
"databaseURL": "...",
"projectId": "...",
"storageBucket": "...",
"messagingSenderId": "...",
"appId": "...",
"measurementId": "..."
};
firebase = pyrebase.initialize_app(config)
dados = firebase.database()
users = dados.child('mover').get()
mov = users.val()
print(mov)
if mov == 'True':
print('true')
elif mov == 'False':
print('false')
你要找的是 value
,使其更加晶莹剔透。
from collections import OrderedDict
# creating a simple dict
my_dict = {'move': True}
# creating ordered dict from dict
ordered_dict = OrderedDict(my_dict)
for k,v in ordered_dict.items():
print(v)
OUTPUT:
True
一句话。
print(list(ordered_dict.values())) # [True]
在你的具体情况下,
print(list(mov.values())[0]) # True