擅长:python、mysql、java
<p>这可能就是你要找的。
有一个“后台进程”正在运行,同时使用两个单独的线程等待您的输入</p>
<pre><code>import time
import threading
def myInput():
print("Type your name when ready!")
name = input()
print("Your name is: ", name)
def backgroundProcess():
while (True):
print("Some code is running...")
time.sleep(1)
inputThread = threading.Thread(target=myInput)
processThread = threading.Thread(target=backgroundProcess)
inputThread.start()
processThread.start()
</code></pre>