argparse.ArgumentParser()讲解

argparse.ArgumentParser()是参数的容器,写参数时--命名规定,在调用参数是需要去掉--。
parser = argparse.ArgumentParser()
parser.add_argument('--prepared-train-labels', type=str,default=r'../../untitled/scripts/prepared_train_annotation.pkl',
                        help='path to the file with prepared annotations')
args = parser.parse_args()
print(args.prepared_train_labels)
输出结果
../../untitled/scripts/prepared_train_annotation.pkl
posted @ 2022-03-06 22:20  祥瑞哈哈哈  阅读(128)  评论(0)    收藏  举报