如:在a.py文件有一个变量a = bool(),b.py去运行a.py,然后我希望能获取a.py运行后a的值,该如何去获取?
认证高级PHP讲师
Yes, you must declare it before using itglobal a
global a
Oops, the file name and variable name are duplicated. In b.py, import a to get the global variables in the a.py file
a.py
a = 1 b = "2" def f(): return "function"
b.py
import a a = a.a from a import b,f print(b) f()
Yes, you must declare it before using it
global a
Oops, the file name and variable name are duplicated.
In b.py, import a
to get the global variables in the a.py file
a.py
b.py