我正在运行脚本python test.py ab_mr1
,输出应该是"ab_mr1"
for branch_name
,但它打印为 emtpy 值,知道为什么吗?
test1.py
:
import os
import sys
import test
def main():
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"
test.main(BranchName) # here I am passing the variable
print "After running test1"
if __name__ == '__main__':
main()
test.py
:
branch_name=''
def main(branch_name):
print('In test.py, the value is: {0}', branch_name)
if __name__ == '__main__': # need this
main(branch_name)
电流输出:
('In test.py, the value is: {0}', '')
预期输出:
('In test.py, the value is: {0}', 'ab_mr1')