python多線程共享全局變量的問題

線程之間共享全局變量的問題 import time import random import threading g_num = 100 def work1(): global g_num #全局變量在函數中使用須要申明 for i in range(3): g_num+=1 time.sleep(random.random())
相關文章
相關標籤/搜索