In Python, you can use the Os.listdir () function to get the contents of the specified directory. Its prototype is shown below.
os.listdir (path)The parameters have the following meanings. Path to get the paths to the content directory. The following instance obtains the contents of the current directory. >>> Import os >>> os.listdir (OS.GETCWD ()) Get the contents of the current directory [' Dde.pyd ', ' license.txt ', ' Pythonwin.exe ', ' s Cintilla.dll ', ' win32ui.pyd ', ' win32uiole.pyd ', ' Pywin '] How to create a directory in a Python programming language you can use the Os.mkdir () function to create a directory in Python. Its prototype is shown below.
os.mkdir (path)Its parameter meaning is. path where you want to create the directory. The following instance creates the Temp directory under the E:\book directory. >>> Import os >>> os.mkdir (' e:\\book\\temp ') use Os.mkdir to create a directory delete directory in Python you can use the Os.rmdir () function to delete a directory. Its prototype is shown below.
os.rmdir (path)The parameters have the following meanings. Path of the directory to be deleted by path. The following instance deletes the E:\book\temp directory. >>> Import os >>> os.rmdir (' e:\\book\\temp ') to remove a directory, it is important to note that directories that are deleted using Os.rmdir must be empty directories or the function will fail. The above is a description of how the Python programming language obtains content from the directory, creates a directory, and how to remove the contents of the directory in the Python programming language.
OS module functions "Python" for directory Processing