84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
如:在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