1
有這個進程之間共享狀態的documentation,但它並沒有完全回答我的問題。我有以下代碼在多進程之間共享進程之間的狀態
from multiprocessing import Process, Value, Array
#This is my function
def my_func(my_array):
my_array = ["hello", "hi", "howdy"]
# I am initiating an array called arr that has string elements here
if __name__ == '__main__':
arr = Array('c')
p = Process(target=my_func, args=(arr))
p.start()
p.join()
print(arr[:])
我想通過常用3月底等於["hello", "hi", "howdy"]
,但我的代碼不能正常工作。有誰知道爲什麼?