我有一个代码,用于使用 Tweepy 库抓取流式推文 Python 。 我想在不停止在 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