此方法用於爬蟲效果極優
import threading
import time
def testa(n):
while True:
time.sleep(1)
print(n)
#先隔出一秒打印出a,再過一秒打出b
ts = []
for i in range(5):
exec('t{0} = threading.Thread(target=testa,args=(i,))'.format(i))
exec('ts.append(t{0})'.format(i))
for s in ts:
s.start()
print("DONE")