The python os library has many functions related to the operating system.
In fact, it’s not just that. There are many things related to files, paths, and execution of system commands in the os library.
The following are the commonly used methods of the os module.
1.os.sep using os module. For example, for Windows, it is 'nt', and for Linux/Unix users, it is 'posix'
3.os.getcwd() The function gets the current working directory, which is the directory path where the current Python script works
6.os.listdir () Return all files and directory names in the specified directory
7os.remove () function for Delete a file
8.os.system() The function is used to run shell commands
15. os.getcwd() Get the current working directory
16.os.curdir Return the previous directory ('.')
17.os.chdir(dirname) Change the working directory to dirname
os.path.isfile(name) Determines whether name is a directory File, if name does not exist, it will return false
os.path.exists(name) Determine whether the file or directory name exists
os.path.getsize(name) Get the file size, if name is a directory, return 0L
os.path.abspath( name) Get the absolute path
os.path.normpath(path) Normalize the path string form
os.path.split(name) Split the file name and directory (in fact, if you use the directory entirely, it will also split the last directory Separated as a file name, and it does not determine whether the file or directory exists)
os.path.splitext() Separates the file name and extension
os.path.basename(path) Returns the file name
os.path.dirname(path) Returns the file path