线程 Threading
import time
from threading import Thread
def func():
while True:
time.sleep(0.5)
print(123)
def func2():
print("func2 start ")
time.sleep(3)
print("func2 end")
t1 = Thread(target=func)
t2 = Thread(target=func2)
t1.setDaemon(True) #将t1变成守护线程
t1.start()
t2.start()
print("主线程代码结束")