os***********
OS.SEP can replace the operating system-specific path delimiter. windows for ' \ \ '
The Os.name string indicates the platform you are using. For example, for Windows, it's ' NT ', and for Linux/unix users, it's ' POSIX '
The OS.GETCWD () function gets the current working directory, which is the directory path of the current Python script work
Os.getenv () Gets an environment variable if none is returned
Os.putenv (key, value) sets an environment variable value
Os.listdir (path) returns all file and directory names under the specified directory
The Os.remove (path) function is used to delete a file
Os.system (command) function to run the shell command
The OS.LINESEP string gives the line terminator used by the current platform. For example, Windows uses ' \ r \ n ', Linux uses ' \ n ' and Mac uses ' \ R '
The Os.path.split (path) function returns the directory name and file name of a path
The Os.path.isfile () and Os.path.isdir () functions respectively verify that the given path is a file or a directory
The os.path.exists () function is used to verify that the given path really exists
Os.curdir returns the current directory ('. ')
Os.mkdir (path) Create a directory
Os.makedirs (path) to create a directory recursively
Os.chdir (dirname) Change working directory to DirName
Os.path.getsize (name) Gets the file size if name is directory returned 0L
Os.path.abspath (name) gets the absolute path
Os.path.normpath (path) canonical path string form
Os.path.splitext () detach file name and extension
Os.path.join (path,name) connection directory with file name or directory
Os.path.basename (path) returns the file name
Os.path.dirname (path) return file path
Os.walk (top,topdown=true,onerror=none) Traversal Iteration Directory
Os.rename (SRC, DST) rename file or directory src to DST if DST is an existing directory, the OSError will be thrown. In Unix, if DST is stored and is a file, it will be silently replaced if the user has permission. The operation will fail in some UNIX if SRC and DST are in different file systems. If successful, this naming operation will be an atomic operation (this is POSIX required). On Windows, if DST already exists, OSError will be thrown, even if it is a file. Valid in Unix,windows.
Os.renames (old, new) recursively renames a folder or file. Like rename ()
shutil********************
Shutil.copyfile (SRC, DST) is copied from source Src to DST. The premise is, of course, that the destination address has writable permissions. The exception information thrown is IOException. If the current DST already exists, it will be overwritten.
Shutil.move (SRC, DST) move files or rename
Shutil.copymode (SRC, DST) just replicates its permissions other things are not copied
Shutil.copystat (SRC, DST) copy permissions, last access time, last modified time
Shutil.copy (SRC, DST) copy a file to a file or a directory
Shutil.copy2 (SRC, DST) copy files on the basis of copy the last access time and modification time are also copied, similar to cp–p things
Shutil.copy2 (SRC, DST) if the file system in two locations is the same, it is equivalent to rename operation, just renaming; if it's not the same filesystem, it's a move operation.
Shutil.copytree (Olddir, Newdir, True/flase)
Copy the Olddir to a newdir, if the 3rd parameter is true, the symbol connection under the folder will be kept when the directory is copied, and if the 3rd parameter is false, a physical copy will be generated in the replicated directory instead of the symbolic connection
Shutil.rmtree (SRC) recursively deletes a directory and all content within the directory
shutil.rmtree(path) #递归删除文件夹
sys************************
SYS.ARGV command line argument list, the first element is the path of the program itself
Sys.modules.keys () returns the list of all modules that have been imported
Sys.exc_info () Gets the exception class currently being processed, Exc_type, Exc_value, exc_traceback the exception details currently handled
Sys.exit (n) exit program, Exit normally (0)
Sys.hexversion gets the version value of the Python interpreter, 16 binary format such as: 0x020403f0
Sys.version get version information for Python interpreter
Sys.maxint the largest int value
Sys.maxunicode the largest Unicode value
Sys.modules returns the module field of the system import, key is the module name, value is the module
Sys.path returns the search path for the module, using the value of the PYTHONPATH environment variable when initializing
Sys.platform returns the operating system platform name
Sys.stdout Standard Output
Sys.stdin Standard input
Sys.stderr Error Output
Sys.exc_clear () to clear current or recent error messages that are present on the current thread
Sys.exec_prefix returns the location of the platform standalone Python file installation
Sys.byteorder The local byte rule indicator, the value of the Big-endian platform is ' big ', the value of the Little-endian platform is ' little '
Sys.copyright record python copyright-related things
API version of C for the Sys.api_version interpreter
Python's os,shutil and SYS modules