The SYS module includes a set of very useful services that contain a number of function methods and variables to handle the Python run-time configuration and resources to interact with the system environment outside of the previous program, such as the Python interpreter.
1. Import SYS module
First, open the terminal emulator into the Python interpreter or open the IDE editor to create a new. py suffix name of the Python program file.
Here is an example of an action in an interpreter:
>>> Import SYS #导入sys模块
>>> dir (SYS) #dir () method to view the methods available in the module
Note: If you are in the editor, be sure to notice the code in advance, otherwise Chinese will be garbled.
2. SYS module IMPORTANT function variable
1) Sys.stdin standard input stream.
2) sys.stdout standard output stream.
3) Sys.stderr standard error stream.
4) Sys.path The list of directory names for the directory where the module resides.
5 sys.argv the command line parameters, including the script name.
6) Sys.platform return to the current system platform, such as: Win32, Linux and so on.
3. Sys Common method usage instruction
The Sys.exit method can exit the current program and provide an integer type, usually using the 0 function as the parameter of this method,
Of course, you can also use string parameters to indicate error information that is not successful.
The Sys.modules method can map the name of a module to a real-world module, and it applies only to the currently imported module.
There are 3 module variables: Sys.stdin, sys.stdout, Sys.stderr They are class file (File-like) stream objects.
Source: http://www.iplaypython.com/module/sys.html