argparse.ArgumentParser

实例化一个对象,默认参数一堆,只有description参数可以设置一下
parser=argparse.ArgumentParser( description="This is a example program ")
add_help:默认是True,可以设置False禁用



class ArgumentParser(_AttributeHolder, _ActionsContainer)
 |  Object for parsing command line strings into Python objects.
 |  
 |  Keyword Arguments:
 |      - prog -- The name of the program (default: sys.argv[0])
 |      - usage -- A usage message (default: auto-generated from arguments)
 |      - description -- A description of what the program does
 |      - epilog -- Text following the argument descriptions
 |      - parents -- Parsers whose arguments should be copied into this one
 |      - formatter_class -- HelpFormatter class for printing help messages
 |      - prefix_chars -- Characters that prefix optional arguments
 |      - fromfile_prefix_chars -- Characters that prefix files containing
 |          additional arguments
 |      - argument_default -- The default value for all arguments
 |      - conflict_handler -- String indicating how to handle conflicts
 |      - add_help -- Add a -h/-help option
 |      - allow_abbrev -- Allow long options to be abbreviated unambiguously
 |  
 |  Method resolution order:
 |      ArgumentParser
 |      _AttributeHolder
 |      _ActionsContainer
 |      builtins.object
 |  
 |  Methods defined here:
 |  
 |  __init__(self, prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |  
 |  add_subparsers(self, **kwargs)
 |      # ==================================
 |      # Optional/Positional adding methods
 |      # ==================================
 |  
 |  convert_arg_line_to_args(self, arg_line)
 |  
 |  error(self, message)
 |      error(message: string)
 |      
 |      Prints a usage message incorporating the message to stderr and
 |      exits.
 |      
 |      If you override this in a subclass, it should not return -- it
 |      should either exit or raise an exception.
 |  
 |  exit(self, status=0, message=None)
 |      # ===============
 |      # Exiting methods
 |      # ===============
 |  
 |  format_help(self)
 |  
 |  format_usage(self)
 |      # =======================
 |      # Help-formatting methods
 |      # =======================
 |  
 |  parse_args(self, args=None, namespace=None)
 |      # =====================================
 |      # Command line argument parsing methods
 |      # =====================================
 |  
 |  parse_known_args(self, args=None, namespace=None)
 |  
 |  print_help(self, file=None)
 |  
 |  print_usage(self, file=None)
 |      # =====================
 |      # Help-printing methods
 |      # =====================
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from _AttributeHolder:
 |  
 |  __repr__(self)
 |      Return repr(self).
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from _AttributeHolder:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from _ActionsContainer:
 |  
 |  add_argument(self, *args, **kwargs)
 |      add_argument(dest, ..., name=value, ...)
 |      add_argument(option_string, option_string, ..., name=value, ...)
 |  
 |  add_argument_group(self, *args, **kwargs)
 |  
 |  add_mutually_exclusive_group(self, **kwargs)
 |  
 |  get_default(self, dest)
 |  
 |  register(self, registry_name, value, object)
 |      # ====================
 |      # Registration methods
 |      # ====================
 |  
 |  set_defaults(self, **kwargs)
 |      # ==================================
 |      # Namespace default accessor methods
 |      # ==================================
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值