[참고]

Argparse Tutorial

https://docs.python.org/3.9/howto/argparse.html#id1

https://docs.python.org/3/library/argparse.html?highlight=argparse

 

  • argparse 모듈은 커맨드 라인 인터페이스에 적용하기 쉽게 만들어진 모듈
  • argparse 모듈은 자동으로 help를 생성하고 사용자가 프로그램에 잘못된 인수를 넣으면 사용 메시지와 에러 메시지를 생성함

ArgumentParser objects

class argparse.ArgumentParser(prog=Noneusage=Nonedescription=Noneepilog=Noneparents=[]formatter_class=argparse.HelpFormatterprefix_chars='-'fromfile_prefix_chars=Noneargument_default=Noneconflict_handler='error'add_help=Trueallow_abbrev=True)

Create a new ArgumentParser object. All parameters should be passed as keyword arguments. Each parameter has its own more detailed description below, but in short they are:

  • prog - The name of the program (default: sys.argv[0])
  • usage - The string describing the program usage (default: generated from arguments added to parser)
  • description - Text to display before the argument help (default: none)
  • epilog - Text to display after the argument help (default: none)
  • parents - A list of ArgumentParser objects whose arguments should also be included
  • formatter_class - A class for customizing the help output
  • prefix_chars - The set of characters that prefix optional arguments (default: ‘-‘)
  • fromfile_prefix_chars - The set of characters that prefix files from which additional arguments should be read (default: None)
  • argument_default - The global default value for arguments (default: None)
  • conflict_handler - The strategy for resolving conflicting optionals (usually unnecessary)
  • add_help - Add a -h/--help option to the parser (default: True)
  • allow_abbrev - Allows long options to be abbreviated if the abbreviation is unambiguous. (default: True)

Changed in version 3.5: allow_abbrev parameter was added.

The following sections describe how each of these are used.

'#Learn More Python3 the Hard Way #제드 쇼 ' 카테고리의 다른 글

#python #연산자  (0) 2019.07.11
# 구식 문자열 포맷  (0) 2019.07.10

+ Recent posts