-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