Python os Function

Python os module can be used for system operations and do not need to consider the operating system differences(e.g., the difference between Linux, Windows, MacOS). Major attributes and methods list of os module:

Method/Attribute Description os.linesep strings for line separation os.sep separator for file path os.curdir current directory os.pardir parent directory os.remove() delete file os.rename() rename file os.walk() get all file names of directory os.chdir() change working directory os.mkdir create directory os.mkdirs create multi-level directory os.listdir get all files of a directory os.getcwd() get current working directory os.chmod() change the access attributes of directory os.path.basename() get file name out of file path os.path.dirname() get directory path of a file path os.path.join() join separate parts into a file path os.path.split() get separate parts of a file path, include dirname() and basename() os.path.splitext() get file name and extension os.path.getatime() most recent visit time os.path.getctime() create time os.path.getmtime() most recent modify time os.path.getsize() get file size os.path.exists() check file exist or not os.path.isabs() check the file path is a absolute path or not os.path.isdir() check the path is a directory of not os.path.isfile() check the path is a file or not
Python Tutorials
endmemo.com © 2024  | Terms of Use | Privacy | Home