Python OS simple file / directory operations
The Python OS module contains a directory of files and processing method, referred to herein include a few
Incomplete parameter list
Delete, create and other operations
os.mkdir(path)
: Create a file called the working directorypath
folderos.remove(path)
: Delete the path topath
the file, if the file does not exist or is a folder will be thrownOSError
os.rmdir(path)
: Delete calledpath
empty file folder, if the folder is not empty is thrownOSError
os.removedirs(path)
: Recursively delete a folderos.rename(src, dst)
: The specified file / folder (src
) Renamedst
Access operations
os.walk(top)
: Sequentially access a foldertop
for all files and directories, and a return value triples, each clip file being accessed addresses, all the sub-clip files being accessed folder (list
type), the file being accessed folder All files (list
types)os.listdir(path)
: Returnpath
all of the folders and files directory (list
type)