【发布时间】:2020-05-09 01:39:27
【问题描述】:
我在这里有一些代码每分钟打印一次,但我想更改它,以便它直接打印一分钟的消息,然后无限期地暂停一分钟。我如何做到这一点?
import time
while True:
print("This prints once a minute.")
time.sleep(60) # Delay for 1 minute (60 seconds).
【问题讨论】:
-
“连续打印一分钟消息”是指每秒打印一次吗?
-
使用 cron 或你的操作系统调度器
-
你做过研究吗?我相信这样的问题已经被问过很多次了。
标签: python python-3.x time while-loop