【发布时间】:2013-03-20 14:33:25
【问题描述】:
我不知道 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
【问题讨论】:
-
你到底有什么问题?
-
当代码从客户端接收数据并且我按下键盘上的's'键时,当我按下键时打印停止不打印,它需要在打印“停止”之前接收另一个数据打印在屏幕上
标签: python multithreading sockets keypress