运行 python脚本一个月不停

Run python script for one month non-stop

我有一个使用 Python 的 Tweepy 库来抓取流式推文的代码。 我想在 Mac 上不停地抓取流媒体推文一个月。 能从技术角度告诉我怎么做吗?

只用时间模块

import time
print(time.strftime("%b", time.localtime(time.time())))
>>> Jun

您可以像这样有条件地检查月份:

print(time.strftime("%b", time.localtime(time.time())) == "Jun")
>>> true

只需在 while 循环中执行您的程序

while time.strftime("%b", time.localtime(time.time())) == "Jun":
     # your code here