#多线程爬虫
import threading
class One(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
for i in range(0,10):
print("我是线程1")
class Two(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
for i in range(0,10):
print("我是线程2")
t1 = One()
t1.start()
t2 = Two()
t2.start()
#因为是多线程,所以最后的输出结果“我是线程1”和“我是线程2”是交叉输出的
#而如果是函数的话,会先输出“我是线程1”,然后再输出“我是线程2”