简体   繁体   English

Python 脚本:语法错误

[英]Python script: Syntax error

I am trying to program a DHT11 temperature and Humidity sensor using my Raspberry Pi 3 model B. I am using a Python script on the shell, but it is not working because here because of a syntax error.我正在尝试使用我的 Raspberry Pi 3 B 型对 DHT11 温度和湿度传感器进行编程。我在外壳上使用 Python 脚本,但由于语法错误,它无法正常工作。 请在下面的链接中找到我的脚本捕获。 I am trying to run it on the raspberry pi terminal and the error message is in the print statement.我正在尝试在 raspberry pi 终端上运行它,错误消息在打印语句中。

You are missing parenthesis around the print statements.您在打印语句周围缺少括号。 The correct syntax is:正确的语法是:

print("Temperature: ", temperature," C   humidity: ", humidity)

Python 3 requires print statements containing text to be inside of (" "), variables inserted like: Python 3 要求包含文本的打印语句位于 (" ") 内,插入的变量如下:

print(" text ", variable, "more text")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM