Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果Firebase数据使用Python更改,如何调用函数_Python_Database_Firebase_Function_Pyrebase - Fatal编程技术网

如果Firebase数据使用Python更改,如何调用函数

如果Firebase数据使用Python更改,如何调用函数,python,database,firebase,function,pyrebase,Python,Database,Firebase,Function,Pyrebase,当Firebase值更改时,我需要调用一个函数(本例中为print())。我的脚本是用python编写的。据我所知,我已经尝试了一切,但我唯一能观察到的是控制台中的变化,而不是执行任何函数 def stream_handler(message): print(message["event"]) # put print(message["path"]) # /-K7yGTTEp7O549EzTYtI print(message[&qu

当Firebase值更改时,我需要调用一个函数(本例中为print())。我的脚本是用python编写的。据我所知,我已经尝试了一切,但我唯一能观察到的是控制台中的变化,而不是执行任何函数

def stream_handler(message):
    print(message["event"]) # put
    print(message["path"]) # /-K7yGTTEp7O549EzTYtI
    print(message["data"]) # {'title': 'Pyrebase', "body": "etc..."}


def print2(): 
    #it is a example
    print('Print a example')

my_stream = db.child("posts").stream(stream_handler)

print2()

您的
print
在python中覆盖了现有的
print
函数。因此,这段代码只会进入一个无限循环。你测试的时候就是这样吗?对不起。。。为了避免混淆,我修改了代码。我树立了一个坏榜样。。。