python 引用传递,简单例子

Posted on 2021-08-27 16:43  Great-great  阅读(47)  评论(0编辑  收藏  举报
from threading import Thread



def test1(a):
while 1:
print a

def test2(a):
a["a"] = 2

if __name__ == "__main__":
a = {"a": 1}
t1 = Thread(target=test1, args=(a, ))
t1.start()
t2 = Thread(target=test2, args=(a, ))
t2.start()

Copyright © 2024 Great-great
Powered by .NET 9.0 on Kubernetes