-1
我有一个文件example1.py它看起来像一个函数:如何导入全局变量到其他程序
def A():
global var
....
def B():
.....
return x
#calculations using var,function B
return var
def C(var):
....
return something
我想用导入所有功能集成到其他文件example2.py
from example1 import *
我看到函数A在example2.py中正常工作,但函数C没有返回期望值。我的进口有什么问题?
请显示'example2.py'内容。 –
我会建议传递使用全局函数的结果并不是最好的工作方式。每个函数都应该使用一些参数并返回结果,就像您使用'return var'完成的一样[ – scotty3785
]相关[question](https://stackoverflow.com/q/4020419/1435475)。 – guidot