我正在尝试从 test1.py 调用 test.py 中定义的 Branchname 并遇到以下错误,任何人都可以提供输入吗?
测试.py
import test1
import os
import sys
def main():
#initialize global variables & read CMD line arguments
global BranchName
ScriptDir = os.getcwd()
print ScriptDir
BranchName = sys.argv[1]
print "BranchName"
print BranchName
#Update input file with external gerrits, if any
print "Before running test1"
test1.main()
print "After running test1"
if __name__ == '__main__':
main()
测试1.py
import test
def main ():
print test.BranchName
遇到以下错误
BranchName
ab_mr2
Before running test1
Traceback (most recent call last):
File "test.py", line 18, in <module>
main()
File "test.py", line 14, in main
test1.main()
File "/local/mnt/workspace/test1.py", line 3, in main
print test.BranchName
AttributeError: 'module' object has no attribute 'BranchName