所以,首先这是我的代码:
import threading
print "Press Escape to Quit"
class threadOne(threading.Thread): #I don't understand this or the next line
def run(self):
setup()
def setup():
print 'hello world - this is threadOne'
class threadTwo(threading.Thread):
def run(self):
print 'ran'
threadOne().start()
threadTwo().start()
所以,问题是在我的类'threadOne'中运行函数(由线程模块调用)但从那里我不能调用任何其他函数。这包括如果我在 setup() 函数下创建更多函数。例如上面,在我的 run(self) 函数中,我尝试调用 setup() 并得到“NameError: global name 'setup' is not defined”。
有没有人有任何想法或者他们可以向我解释这个?
山姆