Python system modules include sys, OS, glob, socket, threading, _ thread, queue, time, timeit, subprocess, Multiprocessing, signal, select, shutil, and tempfile. Most system-level interfaces are concentrated in the SYS and OS modules.
The SYS module includes:
- Platform and version information, such as SYS. Platform, SYS. maxsize, SYS. Version
- Module search path SYS. Path
- Module table SYS. modules, which contains PythonProgramModule name: module information dictionary
- Exception information, such as SYS. exc_info ()
- Command Line Parameter SYS. argv
- Standard stream, such as SYS. stdin, SYS. stdout, SYS. stderr
- Program exit Call SYS. Exit
OS module inclusion
Tasks |
Tools |
Shell Variables |
OS. Environ |
Running programs |
OS. System, OS. popen, OS .exe CV, OS. spawnv |
Spawning Processes |
OS. Fork, OS. Pipe, OS. waitpid, OS. Kill |
Descriptor files, locks |
OS. Open, OS. Read, OS. Write |
File Processing |
OS. Remove, OS. Rename, OS. mkfifo, OS. mkdir, OS. rmdir |
Administrative Tools |
OS. getcwd, OS. chdir, OS. chmod, OS. getpid, OS. listdir, OS. Access |
Portability tools |
OS. SEP, OS. pathsep, OS. curdir, OS. Path. Split, OS. Path. Join |
Pathname tools |
OS. Path. exists ('path'), OS. Path. isdir ('path'), OS. Path. getsize ('path ') |
In the sys and OS modules, operations related to Python programs include:
- OS. getcwd (): obtains the current path when the script is running.
- OS. chdir (): change the path
- SYS. Path: Search Path of the module used in the storage Program
- SYS. argv: the parameter of the python program in the command line running state. The first parameter is always the name of the Python script.
- OS. Environ: a dictionary for storing shell variables. The content is stored in key-value format.