import threading #线程
import time
class Work(threading.Thread):
def __init__(self,n):
threading.Thread.__init__(self) #改写父类init方法 并把self 传递过去
self.n = n
def run(self): #run是固定写这的
print(self.n)
t1 = Work(1)
t1.start() #start()就是去调用run方法
转载于:https://www.cnblogs.com/ajaxa/p/9109554.html