我正在尝试按照在Raspberry Pi 2 B +上运行的py代码中使用Firebase的说明进行操作.在python 3上运行时,会发生不好的事情.
我在我的脚本中包含了pyrebase,但是当我使用python3运行它时,我得到了以下内容(请参阅下面的内容).我一直在研究各种其他语言,但我选择了python和Raspberry Pi来实现我想到的项目.
这篇文章将包含我运行代码时获得的代码和终端输出
#import Libraries
import RPi.GPIO as GPIO
import time
import pyrebase
import os
#Firebase Configuration
config = {
"apiKey": "apiKey",
"authDomain": "rpitest-xxxxx.firebaseapp.com",
"databaseURL": "rpitest-xxxxx.firebaseio.com",
"storageBucket": "rpitest-xxxxx.appspot.com"
}
firebase = pyrebase.initialize_app(config)
#GPIO Setup
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(22, GPIO.OUT)
#Firebase Database Intialization
db = firebase.database()
#While loop to run until user kills program
while(True):
#Get value of LED
led = db.child("led").get()
#Sort through children of LED(we only have one)
for user in led.each():
#Check …Run Code Online (Sandbox Code Playgroud)