python 获取另一个.py中变量的值
PHP中文网
PHP中文网 2017-04-18 09:25:12
0
3
412

如:在a.py文件有一个变量a = bool(),b.py去运行a.py,然后我希望能获取a.py运行后a的值,该如何去获取?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
迷茫

Yes, you must declare it before using itglobal 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()
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template