我有下面的代码一个线程用于比较用户输入无法建立在python
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()函数,我无法找到任何错误..提前
谢谢...
你能提供一个最小运行的例子吗?此代码不会运行,因为名称'username'和'password'未定义。 – 2012-04-28 14:26:36