Python argparse module

Source: Internet
Author: User

First, Introduction:

Argparse is a standard module used by Python to parse command-line arguments and options in place of obsolete optparse modules. The Argparse module is used to parse command-line arguments, such as Python parsetest.py input.txt output.txt--user=name--port=8080.

Second, the use of the steps:

1:import Argparse

2:parser = Argparse. Argumentparser ()

3:parser.add_argument ()

4:parser.parse_args ()

Explanation: Import the module first, then create a parse object, then add the command line arguments and options you want to follow to the object, each Add_argument method corresponds to a parameter or option that you want to focus on, and the last call to the Parse_args () method to parse it;

Official Document: Https://docs.python.org/2/howto/argparse.html

Official Document Translator: http://www.jianshu.com/p/a50aead61319

Python argparse module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.