擅长:python、mysql、java
<p>首先,你整天运行一个脚本,让它一天只做一次。这是不合逻辑的。你应该在你的操作系统(Win,Linux,Mac)上安排一个任务,这样你的脚本就可以在每天6小时被激活,并删除脚本中的时间条件。在</p>
<p>如果你想变得花哨,创建一个电报机器人,让它在你想要的任何时候,在你的手机上,为你指定的地点向你发送一条消息。在</p>
<p>不过,脚本很容易修复。您使用<code>while</code>循环作为<code>if</code>。只需添加一个变量,使它只发送一次电子邮件。在</p>
<pre><code>if time == 0500:
send_email = True
if send_email and time == 0600:
print('Time is correct')
send_email = False
weather_com_result = pywapi.get_weather_from_weather_com('ASXX0075')
....
</code></pre>