我有以下代码比较用户输入
import thread,sys
if(username.get_text() == 'xyz' and password.get_text()== '123' ):
thread.start_new_thread(run,())
def run():
print "running client"
start = datetime.now().second
while True:
try:
host ='localhost'
port = 5010
time = abs(datetime.now().second-start)
time = str(time)
print time
client = socket.socket()
client.connect((host,port))
client.send(time)
except socket.error:
pass
如果我只是调用函数 run() 它可以工作,但是当我尝试创建一个线程来运行这个函数时,由于某种原因线程没有被创建并且 run() 函数没有被执行我找不到任何错误..
提前致谢...