我已经不知道 python 中的 msvcrt.kbhit() 如何在我单击需要按下的指定键后立即打印出数据。看起来while循环需要再次循环才能打印出我想要的输出。有人可以帮帮我吗。这是我的代码:
def run(self):
global state
print "\nClient connection received!\n"
self.channel.send("Status: Server connection received")
while 1:
ctr = 1
while 1:
self.clientmess = self.channel.recv(Buffer)
if msvcrt.kbhit():
if msvcrt.getch() == 's':
print "stop"
break
#the codes belo is what i will want for self.clientmess will be so its not necessary I think to put