以下不起作用
one.py
import shared
shared.value = 'Hello'
raw_input('A cheap way to keep process alive..')
Run Code Online (Sandbox Code Playgroud)
two.py
import shared
print shared.value
Run Code Online (Sandbox Code Playgroud)
在两个命令行上运行:
>>python one.py
>>python two.py
Run Code Online (Sandbox Code Playgroud)
(第二个得到属性错误,这是正确的).
有没有办法实现这一点,即在两个脚本之间共享一个变量?