OS.GETCWD () Gets the current working directory, which is the directory path of the current Python script workOs.chdir ("dirname") changes the current script working directory, equivalent to the shell CDOs.curdir Returns the current directory: ('. ')
Os.pardir Gets the parent directory string name of the current directory: (' ... ')os.makedirs (' dirname1/dirname2 ') can generate multi-level recursive directoriesos.removedirs (' dirname1 ') if the directory is empty, then delete, and recursively to the previous level of the directory, if also empty, then delete, and so onos.mkdir (' dirname ') generates a single-level directory, equivalent to mkdir dirname in the shellos.rmdir (' dirname ') delete the single-level empty directory, if the directory is not empty can not be deleted, error, equivalent to the shell rmdir dirnameos.listdir (' dirname ') lists all files and subdirectories in the specified directory, including hidden files, and prints as a listos.remove () delete a fileos.rename ("Oldname", "newname") renaming files/directoriesos.stat (' path/filename ') get File/directory informationOS.SEP output operating system-specific path delimiter, win under "\ \", Linux for "/"os.linesep Output The line terminator used by the current platform, win under "\t\n", Linux "\ n"os.pathsep output string for splitting the file pathThe os.name output string indicates the current usage platform. Win-> ' NT '; Linux-> ' POSIX 'os.system ("Bash command") runs a shell command that directly displaysOs.environ getting system environment variablesOs.path.abspath (path) returns the absolute path normalized by pathos.path.split (path) splits path into directory and file name two tuples returnedos.path.dirname (path) returns the directory of path. is actually the first element of Os.path.split (path)os.path.basename (path) returns the last file name of path. If path ends with a/or \, then a null value is returned. The second element of Os.path.split (path)os.path.exists (path) returns true if path exists, false if path does not existos.path.isabs (path) returns True if path is an absolute pathos.path.isfile (path) returns True if path is a file that exists. Otherwise returns falseos.path.isdir (path) returns True if path is a directory that exists. Otherwise returns falseOs.path.join (path1[, path2[, ...]) When multiple paths are combined, the parameters before the first absolute path are ignoredos.path.getatime (path) returns the last access time of the file or directory to which path is pointing
Os.path.getmtime (Path) returns the last modified time of the file or directory to which path is pointing
################## type Conversion ##################
Chr (i) turn an ASCII value into the character ord (i) to turn a character or Unicode character into an ASCII value
Oct (x) turns integer x into a string represented by octal
Hex (x) turns integer x into a hexadecimal-represented string
STR (obj) gets the string description of obj
List (seq) converts a sequence into a list
Tuple (seq) converts a sequence into a tuple
Dict (), Dict (list) converted to a dictionary
int (x) is converted to an integer
Long (x) converts to a long interger
Float (x) is converted to a floating-point number Complex (x) converted to plural max (...) to maximize min (...) to find minimum
#########################################
Help (obj) online, obj is any type
Callable (obj) to see if an obj can be called like a function
Repr (obj) obtains a representation string of obj that can be used to reconstruct a copy of the object using the string eval
Eval_r (str) represents a valid Python expression that returns the expression
Dir (obj) to view the name visible in the name space of obj
Hasattr (obj,name) See if there is a name in the name space of obj
GetAttr (obj,name) gets a name in the name space of obj
SetAttr (Obj,name,value) is the name of an obj
A name in space points to Vale, the object
Delattr (obj,name) removes a name from the name space of obj
VARs (obj) returns the name space of an object. expressed in Dictionary
Locals () returns a local name space, denoted by dictionary
Globals () returns a global name space, denoted by dictionary
Type (obj) to view the types of an obj
Isinstance (OBJ,CLS) to see if obj is a CLS instance
Issubclass (subcls,supcls) View Subcls is not a subclass of Supcls
The os.module;building_in_module of Python