Registros de problemas dispersos

1. módulo argparse

('--version_2_with_negative', action='store_true'El valor predeterminado es Falso, debe pasarse al pasar parámetros --version_2_with_negativepara que sea verdadero

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)

Supongo que te gusta

Origin blog.csdn.net/qq_23590921/article/details/122195564
Recomendado
Clasificación