Os.listdir (dirname): Lists directories and files under DirName os.getcwd (): Get current working directory Os.curdir: Returns the current directory ('. ') Os.chdir (dirname): Change the working directory to Dirnameos.path.isdir (name): Determine if Name is a directory, name is not a directory and return Falseos.path.isfile (name): Determine if name is a file, does not exist name also returns Falseos.path.exists (name): Determine if there is a file or directory Nameos.path.getsize (name): Get the file size, If name is the directory return 0los.path.abspath (name): Gets the absolute path Os.path.normpath (path): Canonical path string form Os.path.split (name): Split file name and directory (in fact, If you use the directory completely, it will also separate the last directory as the file name, and it will not determine if the file or directory exists) Os.path.splitext (): Detach the filename with the extension os.path.join (path,name): Connection directory with file name or directory Os.path.basename (PATH): Returns the file name Os.path.dirname (path): Returns the path Os.remove (dir) #dir为要删除的文件夹或者文件路径os. RmDir ( Path) #path要删除的目录的路径. It should be explained that the directory deleted using Os.rmdir must be an empty directory, or the function will fail. Os.path.getmtime (name) # Gets the file's modified time Os.stat (path). st_mtime# Gets the modified time of the file Os.stat (path). St_ctime # Gets the file modification time Os.path.getctime (name) #获取文件的创建时间
The OS module of the Python module is detailed