python 命令行参数获取

import argparse

parser = argparse.ArgumentParser(description='Real-Time Filtering evaluation script - Scenario B (version 1.0)')
parser.add_argument('-q', required=False, metavar='qrels', help='qrels file')
parser.add_argument('-c', required=True, metavar='clusters', help='cluster anotations')
parser.add_argument('-r', required=True, metavar='run', help='run file') args = parser.parse_args()
file_qrels_path = vars(args)['q']
clusters_path = vars(args)['c']
run_path = vars(args)['r']

=======>>

Thhs-MacBook-Pro:eval apple$ python 1torank.py --help
usage: 1torank.py [-h] [-q qrels] -c clusters -r run

Real-Time Filtering evaluation script - Scenario B (version 1.0)

optional arguments:
-h, --help show this help message and exit
-q qrels qrels file
-c clusters cluster anotations
-r run run file

上一篇:python面试题300道答案参考1


下一篇:numpy自动生成数组