小编cmb*_*oks的帖子

Python while 循环语法无效

在我展示代码之前,只是提供一些我正在处理的项目的背景知识。我目前正在开发一个 Python 脚本,该脚本将在 Raspberry Pi 上运行,以监控地下室污水泵的浮子开关。此代码将检查污水泵是否不符合以下两个标准:

  1. 如果开关打开超过三分钟
  2. 如果开关在三分钟内打开和关闭超过 10 次

我还没有完成其余的代码,但这是我所拥有的:

import time

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
floatSwitch = GPIO.input(17)

import smtplib

running = True
log = open("sumpPumpLog.txt", "r+")
startTime = time.time()


def elapsedTime():
    """This function checks how much time
    has elapsed since the timer has started"""
    endtime = time.time()
    elapsed = endtime - starttime
    return elapsed


def sendEmail(*msg):
    """This function sends an email to selected recipients with a custom
    message as well as the log file …
Run Code Online (Sandbox Code Playgroud)

python while-loop

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

python ×1

while-loop ×1