使用进程实现多任务教程
import time
#进程实现多任务的步骤:
# 1.导入模块:
from multiprocessing import Process
def sing():
for i in range(3):
time.sleep(1)
print('唱第%d首歌儿'%i)
def dance():
for i in range(3):
time.sleep(1)
print('跳第%d段舞蹈'%i)
if __name__ == '__main__':
#2.创建进程
p = Process(target=sing)
#3.启动
p.start()
dance()`在这里插入代码片`