Invoking the interpreter Argument passing

Source: Internet
Author: User

When the Python interpreter is learned, the appended parameter information (thereafter) after the script name is shifted (turn into) to become a list of strings and then passed to the ARGV variable in the SYS module in Python. You can access this parameter list by executing the following code:

Import Sysy

Then the requirement is that the element in the list of this parameter has at least one item (at least). When the script name is not passed, and no arguments are passed, the value of the variable sys.agrv[0 in the SYS module will be empty. When the name of the script is specified as "-" means that the input (meaning) is from the standard input, then the sys.argv[0] value will be set to "-". Similarly, when the selected "-C" is used, then sys.argv[0] will be set to (set to) "-C". The selected "-M" specifies Yes, then represents the input source with a module, then the value of Sys.argv[0] is set to the full path form of the module name at cost. After setting the "-C" or "-m" instruction, the subsequent options will no longer be handed to the Python interpreter (not consumed by Python interpreter ' s), but remain in the (left in) sys.argv for "-C" Or "-M" point to the command or module to handle.


Invoking the interpreter Argument passing

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.