零散问题记录

1.argparse模块

('--version_2_with_negative', action='store_true'的默认值是False,需要在传参时传入--version_2_with_negative才是true

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)

你可能感兴趣的:(python)