我需要两件事来做: 1)事情要不断地发生;2)当时机成熟时,事情就会发生,就像:
while True:
print('nothing happening')
if 5_seconds_passed:
print('five seconds passed')我希望输出如下:
...
nothing happening
nothing happening
nothing happening
nothing happening
five seconds passed
nothing happening
nothing happening
...发布于 2022-02-02 20:53:26
如果您想要通过5秒,那么在运行其余代码之前,只需在循环中执行即可。
def 5_seconds_passed(oldepoch):
return time.time() - oldepoch >= 5其中oldepoch是它最后一次运行的时间(在while循环开始之前设置)
https://stackoverflow.com/questions/70962679
复制相似问题