擅长:python、mysql、java
<p>使用第二个线程(<a href="https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)</a>,<a href="https://stackoverflow.com/questions/2846653/how-to-use-threading-in-python">How to use threading in Python?</a>):</p>
<pre><code>def quit_on_user_input():
input = raw_input("Press any key to quit.")
# thread will lock up and wait for user to input. That's why this is on a separate thread.
sys.exit(0)
quit_thread = threading.Thread(target=quit_on_user_input, args=[])
quit_trhead.start()
# The rest of your code. quit_thread will run in the background and therefor won't lock up your main thread.
</code></pre>