散在する問題記録

1. argparseモジュール

('--version_2_with_negative', action='store_true'デフォルト値は False です。パラメータを渡すときに--version_2_with_negativetrue にする必要があります。

import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--version_2_with_negative', action='store_true',
                    help='If true, the SQuAD examples contain some that do not have an answer.')
parser.add_argument('--test_variable',default=20, type=int)
args = parser.parse_args()
print(args)
$ python tmp.py 
Namespace(test_variable=20, version_2_with_negative=False)
$ python tmp.py --test_variable 60
Namespace(test_variable=60, version_2_with_negative=False)
$ python tmp.py --test_variable 60 --version_2_with_negative
Namespace(test_variable=60, version_2_with_negative=True)

おすすめ

転載: blog.csdn.net/qq_23590921/article/details/122195564