Python OS module Common features

Source: Internet
Author: User
Tags create directory

The OS module contains common operating system features, and the following list of commonly used commands is as follows:

1. Os.sep: Change the path delimiter in the operating system
2. OS.GETCWD (): Gets the current path, which is more commonly used in Python code
3. Os.listdir (): Lists all files and folders in the current directory
4. Os.remove (): Delete the specified file
5. Os.system (): Run shell command
6. Os.chdir (): Change the current directory to the specified directory
7. Os.name (): Judging the platform that is now being used, Windows returns ' NT '; Linux returns ' POSIX '
8. Os.rmdir (): Delete the specified directory
9. Os.mkdir (): Create directory
Os.path.abspath (): Return the absolute path of path
Os.path.split (): Breaks the path into (folder, file name), returns the tuple type
Os.path.basename (): Returns the file name in path
Os.path.getmtime (): The last modification time of a file or folder, from the new era to the number of seconds to access it
Os.path.getatime (): Last access time for a file or folder, from new era to the number of seconds to access
Os.path.getctime (): The time the file or folder was created, from the new era to the number of seconds it was accessed
Os.path.getsize (): The size of the file or folder, if the folder returns 0
Os.path.isfile (): Determines whether the specified object is a file
Os.path.isdir (): Determines whether the specified object is a directory
Os.path.exists (): Verifies that the specified object exists
Os.path.join (): Connection directory and file name
Os.path.dirname (): Return file path

Python OS module Common features

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.