【发布时间】:2013-04-29 14:31:41
【问题描述】:
在 python 中,是否可以像time.sleep() 一样在脚本休眠时运行代码或执行操作?我想要做的是打印一条消息并仅在打印消息后 10 秒才从用户那里收集输入。我最初虽然我可以做
print "You have ten seconds to answer the question."
print "The question"
time.sleep(10) and input() simultaneously
print "You are out of time"
这可能吗?如果没有,有什么方法可以完成同样的事情吗?
【问题讨论】:
标签: python input thread-sleep