【发布时间】:2010-05-14 04:08:55
【问题描述】:
我今天刚开始学习 Python。我一直在阅读 Byte of Python。现在我有一个涉及时间的 Python 项目。我在 Byte of Python 中找不到任何与时间有关的内容,所以我会问你:
如何在用户指定的时间内运行块然后中断?
例如(在一些伪代码中):
time = int(raw_input('Enter the amount of seconds you want to run this: '))
while there is still time left:
#run this block
甚至更好:
import sys
time = sys.argv[1]
while there is still time left:
#run this block
【问题讨论】:
标签: python