如果收到电子邮件,如何在 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 合作过项目,因此使用它会很理想。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...