Python OS module
Import OS
OS.GETCWD () # The path to the working directory where the Python script is located
Os.chdir (R '/tmp ') # switch directory to TMP
Os.makedirs (R '/a/b/c ') # Create a multi-tiered folder
Os.removedirs (R '/a/b/c ') #删除多层文件夹
Os.mkdir ('/A ') # Create a single folder
Os.listdir (' home ') # List all folders and files
Os.rename (' A ', ' B ') # Modify file names for folders and files
Os.stat (R '/tmp/ans.log ') # file for some time information
OS.SEP # Slash/
Os.linesep #换行符 \ n
OS.PATHSEP # Path delimiter
Os.name # Current system designator win--> ' NT ' linux--> ' POSIX '
Os.system (' ls ') # shell command to run Linux
Os.environ # Display System variables
Os.path.abspath ('. ') # Show absolute path to a relative path
Os.path.split ('/tmp/ans.log ') # splits the path and file name ('/tmp ', ' Ansible.log ')
Os.path.dirname (' Ans.log ') # Lists the folder where the files are located
Os.path.basename ('/tmp/ans.log ') # Remove path only shows file name
Os.path.exists ('/tmp ') # path exists If True does not exist false
Os.path.isabs ('/tmp ') # Whether the path is an absolute path is true no false
Os.path.isfile ('/tmp/ans.log ') # path exists If file is true no false
Os.path.isdir ('/tmp ') # Path exists If folder is True no false
Os.path.join ('/tmp ', ' Ans.log ') #多个路径文件名组合成一个字符串
Os.path.getatime ('/tmp ') # Gets the last access time of the file or folder
Os.path.getmtime ('/tmp ') # Gets the last modified time of the file or folder
The-os of the Python module