raw_input有限的时间?

时间:2012-07-07 00:42:51

标签: python time input

是否有办法为用户提供raw_input,但如果在x时间内没有输入任何内容,则给出空响应("")?我想在脚本启动时给用户10秒钟输入选项,但如果时间到期(或者按Enter键),只需继续脚本即可。如果您了解AppleScript,我希望在python中使用display dialog "Enter options" giving up after 10

1 个答案:

答案 0 :(得分:2)

如果你在unix-land中,你可以使用python的信号库并使用alarm。否则,我认为raw_input完全是线程阻塞的。

有关实施帮助,请参阅this answer