Excerpt from: http://it.100xuexi.com/view/otdetail/20130423/057606dc-7ad1-47e4-8ea6-0cf75f514837.html
1. In Python, you can use the Os.listdir () function to get the contents of the specified directory. Its prototype is shown below.
Path to get the path to the content directory, the following instance obtains the contents of the current directory:
Import OS >>> Os.listdir (OS.GETCWD ())
[' Dde.pyd ', ' license.txt ', ' Pythonwin.exe ', ' scintilla.dll ', ' win32ui.pyd ', ' win32uiole.pyd ', ' Pywin ']
2. In Python, you can use the Os.mkdir () function to create a directory. Its prototype is shown below.
Path to create directory paths, the following instances will create the temp directory under the E:\book directory.
Import OS >>> os.mkdir ('e:\\book\\temp'
3. In Python, you can use the Os.rmdir () function to delete a directory. Its prototype is shown below.
Path to the directory to delete, the following instance deletes the E:\book\temp directory.
Import OS >>> os.rmdir ('e:\\book\\temp')
NOTE: Deleting a table of contents requires that directories deleted using Os.rmdir must be empty directories, or the function will fail.
Python uses the Os.listdir () function to get the contents of a directory