Argparse“ArgumentError: argument -h/--help: conflicting option string(s): -h, --help”

﹥>﹥吖頭↗ 提交于 2019-12-03 09:27:38

argparse adds --help and -h options by default. If you don't want to use the built-in help feature, you need to disable it with:

parser = argparse.ArgumentParser(add_help=False)

See the documentation

The same error pop-ups in 2 other scenarios:

1) Repeated code

parser.add_argument('-h',
                        '--help',
                        action='store_true',
                        help=argparse.SUPPRESS)

parser.add_argument('-h',
                        '--help',
                        action='store_true',
                        help=argparse.SUPPRESS)

2) When you execute the code multiple times on the same kernel

I'm leaving it just in case if someone had simillar problem.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!