Python Argparse Example - Python

How to implement argparse in python?

Snippet Code

Rate this page :
  [ 0 votes]

Argparse is an user friendly command line interface. This argparse command is used to generate usage messages and issues when we enter the code with invalid arguments. The -h option which is known as help is the only free option that we get. Specifying anything else in the code will result in error. The example python code is given below. import argparse parser = argparse.ArgumentParser() parser.add_argument("echo") args = parser.parse_args() print args.echo To run the code: $ python --help


Ask Questions

Ask Question