想在循环里不停检测 我有没有输入s,检测就立即打印出stop消息,问题是while循环应该一直持续不断地自动打印出search,直到我输入 s ,就打印stop,可运行下来需要一直不断按着回车才一步步循环慢慢打印着search下去,这样就失去了使用多线程的意义了。。,希望大神能帮我解决这问题
import threading,sys
x=0
def human():
while 1:
print('search')
if x==1:
break
def stop():
print('stoped')
global x
x=0
#
class tt(threading.Thread):
def run(self):
while 1:
input_kb=str(sys.stdin.readline()).strip("\n")
if input_kb=='s':
print('stop')
global x
x=1
def main():
my_t=tt()
my_t.start()
while True:
human()
stop()
main()