睡觉时做动作

2024-04-19 21:09:58 发布

您现在位置:Python中文网/ 问答频道 /正文

在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"

这可能吗?如果没有,有没有办法完成同样的事情?你知道吗


Tags: theto代码用户answer脚本you消息