from multiprocessing import Process
import time
def demo_one():
print("start")
time.sleep(3)
print("end")
if __name__ == '__main__':
p = Process(target=demo_one)
p.daemon = True # 在start之前设置守护进程,子进程会在主进程结束后直接结束,无论子进程是否执行完
p.start()
print("main")