【发布时间】:2012-03-27 17:23:56
【问题描述】:
我在寻找解决方案时遇到了这个帖子,但它并不能完全满足我的需要:
What is the best way to repeatedly execute a function every x seconds in Python?
这实际上“有效”(或至少第一个解决方案有效),但它不允许您与脚本的其余部分同时进行。
基本上,我需要执行这样的函数:
def functionName():
print "text"
我需要它每隔 100 毫秒执行一次。但我需要这个 while 循环同时循环:
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
我该怎么办?
谢谢!
【问题讨论】:
-
你看threading了吗?