Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法给用户一个 raw_input,但""如果在 x 时间内没有输入任何内容,则给出一个空响应()?我想在脚本启动时给用户 10 秒的时间来输入选项,但是如果时间到期(或者他们按 Enter),只需继续脚本即可。如果你知道 AppleScript,我想display dialog "Enter options" giving up after 10用 python
""
display dialog "Enter options" giving up after 10
如果您在 unix-land 中,您可以使用 python 的信号库并使用警报。否则,我认为raw_input完全是线程阻塞。
raw_input
请参阅此答案以获取实施帮助。