python_import_test2.py文件中导入模块:变化而变化(变量和因变量)在Python
AAA = 'test2'
BBB = AAA + '_BBB'
def showBBB():
print AAA
print BBB
python_import_test1.py文件:
import python_import_test2 as testimport
testimport.AAA = 'test1'
testimport.showBBB()`
作为一个出来,我得到:
test1
test2_BBB
如何获得:
test1
test1_BBB
?
您可以在函数内部而不是在它之前分配'BBB' – khelwood