我希望使用Python只接受用户的某些输入。
因此,在下面的示例中,假设我只想接受‘type2 1/type2 2/type2 3’作为参数。这有可能吗?
parser.add_argument('-t', '--type', type = str, help = 'type1/type2/type3')发布于 2015-07-04 11:05:14
使用 argument将输入限制为有限的一组选择:
parser.add_argument('-t', '--type', choices=('type1', 'type2', 'type3'),
help='type1/type2/type3')https://stackoverflow.com/questions/31219787
复制相似问题