为positionals无效参数我想实现导入功能与必需和可选参数,以这种方式运行此:“需要”在Python命令
python manage.py import --mode archive
在需要--mode
和archive
也。
我正在使用argparse库。
class Command(BaseCommand):
help = 'Import'
def add_arguments(self, parser):
parser.add_argument('--mode',
required=True,
)
parser.add_argument('archive',
required=True,
default=False,
help='Make import archive events'
)
但我recived错误:
TypeError: 'required' is an invalid argument for positionals
'archive'已被**需要,因为它是一个位置参数。 –