Summary of common methods for Python OS modules

Source: Internet
Author: User

The module provides a convenient way to the operating system

Os.environ: Returns the system environment variable OS.GETENV (ENV): Returns the value of the environment variable env os.getpid (): The process of the current program Os.uname (): Returns a System Information object Os.chdir (PATH) : Change Directory OS.GETCWD (): Current directory Os.listdir (path='. ' ): File Os.mkdir in current directory: Create a directory Os.remove (path): Remove file Os.rmdir (path): Remove directory Os.rename (SRC,DST): Rename file Os.readlink ( Path): Read the real address of the linked file Os.path module: Os.path.abspath (path): Put back the absolute path of the current path Os.path.basename (path): Return file name Os.path.dirname (path) : Return directory name Os.path.exist (path): Interpret whether the file or directory exists Os.path.isdir: Determine if the path is a directory Os.path.isfile (path): Determine if the path is a file Os.path.join ( Dirname,basename): Connect directory Name and file name Os.path.split (path): Detach directory Name and file name Os.path.splitext (path): Detach file name (this file name does not contain a suffix) and file suffix

Summary of common methods for Python OS modules

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.