[英]Code is not working, (DHT11 Data to LCD) (Micro:bit) (ERROR: line 3 syntax error can't assign to expression)
由于某种原因,此代码不会停止并显示(错误:第 3 行语法错误无法分配给表达式
#
from I2C_LCD1602_Class import I2C_LCD1602
LCD1620[0] = I2C_LCD1602_Class(0x27)
while True:
lcd.puts("temperature:"+str(temperature()), 0, 0)
lcd.puts("humidity:"+str(humidity()), 2, 0)
if __name__ == '__main__':
sensor = DHT11(pin0)
while True:
try:
temperature, humidity = sensor.read()
print("temperature:"+str(temperature)+" C")
print("humidity:"+str(humidity)+"%")
except Exception as e:
print("Error : " + str(e))
time.sleep(1)
您的第一个 while 循环以“大于”符号而不是冒号结束。 将while True>
更改为while True:
你有
LCD1620(0) = I2C_LCD1602_Class(0x27)
在第三行中,您首先进行 function 调用,然后尝试为该 function 调用分配一个值。 你不能这样做。 也许你的意思是
LCD1620[0] = I2C_LCD1602_Class(0x27)
编辑:顺便说一句,您在第 4 行(如另一个答案中提到的)和第 6 行也有语法错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.