2
現在我的腳本調用通過:Argparse與一個參數的兩個值
python resylter.py -n *newfile* -o *oldfile*
代碼如下所示:
parser.add_argument('-n', '--newfile', help='Uses only with -o argument. Compares inputed OLD (-o) file with previous run results with NEW(-n) output.xml file with actual run results')
parser.add_argument('-o', '--oldfile', help='Uses only with -n argument. Compares inputed OLD (-o) file with previous run results with NEW(-n) output.xml file with actual run results')
和一些行動
如何修改它這樣使用?:
python resylter.py -n *newfile* *oldfile*
sys.argv [-1] di dn't可與nargs = '*'
使用參數'nargs ='*'' –
我不認爲這會有用。我只是把'oldfile'作爲[位置參數](https://docs.python.org/3/library/argparse.html#name-or-flags)(即'parser.add_argument('oldfile',. ..)') – soon