Python and Module--01sys

Source: Internet
Author: User

Sys

Module SYS gives you access to variables and functions that are closely related to the Python interpreter.

function/variable Describe
Argv command-line arguments, including the script name
Exit ([]) Exits the current program and can specify return values or error messages with optional parameters
Modules A dictionary that maps the module name to the loaded module
Path A list that contains the name of the directory in which to find the module
Platform A platform identifier, such as SUNOS5 or Win32
Stdin Standard input stream
StdOut Standard output stream
StdErr Standard error stream

sys.argv

Sys.argv[] is actually a list, inside the item is the user input parameters

#test. py
Import sys

#打印test. pyzero = sys.argv[0]
Print Zero

#打印test the first parameter after the. PY = sys.argv[1]print Primary

#打印含第二个参数之后所有
both = sys.argv[2:]
Print

The results are as follows:

$ python test.py a b c d e ftest.pya['b','C',' D ','e','f']

Python and Module--01sys

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.