Python Study Notes (1): SYS and OS modules

Source: Internet
Author: User

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.

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.