python - 如果收到电子邮件,如何在 Python 中做某事?
问题描述
我正在用 Python 创建一个脚本,每次收到电子邮件时都会打开我的 Phillips Hue 灯。
我希望我的脚本每 60 秒检查一次电子邮件。我一直无法找到任何好方法来做类似的事情,if received email, then
. 所有其他方式似乎也试图解码消息。
我有的代码:
lights = accessing_lights(bridge_ip_var)
while True:
time.sleep(60)
# This would be where there would be some sort of if statement to check if there was an email or not
for light in lights:
lights[light].on = True
lights[light].hue = 7000
lights[light].saturation = 100
time.sleep(3)
for light in lights:
lights[light].on = False
我已经参与过项目,smtplib
因此使用它是理想的。
解决方案
推荐阅读
- python - 如何通过机器人回复触发对话处理程序?[电报机器人] [Python] [python-telegram-bot]
- javascript - 应用程序屏幕变为空白并显示错误(类型错误:分配给常量)
- typescript - Nestjs TypeORM BasicEntity 不遵守命名约定
- html - 如何为硒网络抓取找到正确的 html 元素?
- python - 从文本文件中删除一行中的特定字符
- r - R Shiny visNetwork_2.1.0 中的错误与 visHierarchicalLayout 产生难以辨认的可视化?
- flash - Flash CS6 文件中消失的图形元素
- r - R SQLITE 表更新
- html - 如何使用 HTML 将文本和图像放置在形状内?
- domain-driven-design - 如何处理潜在的域(集成)事件顺序混乱?