小编Chu*_*uka的帖子

argparse .ArgumentParser 引发 ArgumentError

conflict_handler(action, confl_optionals)
  File "/usr/local/lib/python3.6/argparse.py", line 1510, in _handle_conflict_error
    raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument -h/--height: conflicting option string: -h
Run Code Online (Sandbox Code Playgroud)

上面是错误信息,这是我的代码,我没有看到错误:

# 1) 解析参数

parser = argparse.ArgumentParser(description="Description for my parser")
parser.add_argument("-v", "--velocity", action="store", required=True, help="The velocity of the object is required")
parser.add_argument("-a", "--angle", action="store", type=float, required=True, help="The angle of the object is required")
parser.add_argument("-h", "--height", required=False, default= 1.2, help="The height of the object is not required. Default is set to 1.2 meters" )
Run Code Online (Sandbox Code Playgroud)

python argparse

4
推荐指数
2
解决办法
1629
查看次数

标签 统计

argparse ×1

python ×1