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