OS: Provides interfaces to interact with the system
Common methods:
Os.name: Show the platform you are using
Os.system (command): Run shell command
OS.GETCWD (): View working directory
Os.chdir (d): Changing the working directory
Os.listdir (d): View all content in the specified directory
Os.remove (f): Delete the specified file
Os.chmod (F,C): Modify the permissions of the specified file, represented by four octal numbers in Linux
Os.makeirs (DN): Create a directory recursively
Os.mkdir (DN): Create directory, parent directory must exist
Os.rmdir (DN): Delete directory, only last level directory (only empty directory can be deleted)
Os.removedirs (DN): Recursively delete directory, specify last level directory to start deletion (only empty directories can be deleted)
C: Permission f: File dn: directory name
Os.path modules, and path-related modules
Common methods:
Os.path. DirName (P): Show path directory name
Os.path. BaseName (P): Show base name
Os.path. Join (D,B): Splicing directory name and base name
Os.path. Split (P): Return (d,b) tuple
Os.path. GetSize (P): Returns the file size if the file exists and returns an exception if it does not exist
Os.path. Exists (p): Determines whether the specified file exists
Os.path. Isdir (P): Determine if it exists and is a directory
Os.path. Isfile (p): Determines whether the file is present and
Os.path. Ismount (p): Determines whether a mount point
P: Path D: Path directory name B: base name
SYS: module related to Python interpreter
Common methods:
Sys.path (): View the search path for import, returned as a list
SYS.ARGV (): Returns the command line parameters, including the script name, returned as a list
Sys.exit (0): Exit program, custom exit code
sys.stdout: Standard output
Sys.stdin: Standard input
Sys.stderr: Error Output
Sys.executable: Returns the Python interpreter path
This article is from the "Automated Operations" blog, please be sure to keep this source http://hongchen99.blog.51cto.com/12534281/1910792
Python OS, os.path and SYS modules