Python ArgParse
我想使用Python ArgParse只接受用户的某些输入 所以在下面的例子中,假设我只接受'type1/type2/type3'作为参数。可能吗Python ArgParse,python,argparse,Python,Argparse,我想使用Python ArgParse只接受用户的某些输入 所以在下面的例子中,假设我只接受'type1/type2/type3'作为参数。可能吗 parser.add_argument('-t', '--type', type = str, help = 'type1/type2/type3') 使用将输入限制为一组有限的选项: parser.add_argument('-t', '--type', choices=('type1', 'type2', 'type3'),
parser.add_argument('-t', '--type', type = str, help = 'type1/type2/type3')
使用将输入限制为一组有限的选项:
parser.add_argument('-t', '--type', choices=('type1', 'type2', 'type3'),
help='type1/type2/type3')