0
python test.py ab_mr1
으로 스크립트를 실행 중이며 branch_name
의 결과는 "ab_mr1"
이어야합니다.하지만 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')
당신이있는 바로, 어리석은 실수 ... 감사합니다 – user2341103