标签:__name__ glob from end port 结束 roc lob style
# coding:utf-8
from multiprocessing import Process
n = 100
def func():
print("func start...")
global n
n = 0
print("子进程里的n:", n)
print("func end...")
if __name__ == ‘__main__‘:
print("主进程开始.")
p = Process(target=func)
p.start()
p.join()
print("主进程里的n:", n)
print("主进程结束.")
执行结果:
# 主进程开始.
# func start...
# 子进程里的n: 0
# func end...
# 主进程里的n: 100
# 主进程结束.
标签:__name__ glob from end port 结束 roc lob style
原文地址:https://www.cnblogs.com/lilyxiaoyy/p/10966617.html