Python OS module, pythonos

Source: Internet
Author: User

Python OS module, pythonos

I. OS module Overview

The Python OS module contains common operating system functions.

Ii. Common Methods

1. the OS. name output string indicates the platform in use. If it is a window, it is represented by 'nt '. For Linux/Unix users, it is 'posix '.

2. the OS. getcwd () function obtains the current working directory, that is, the directory path of the current Python script.

3. OS. listdir () returns all files and directory names under the specified directory.

4. OS. remove () deletes an object.

5. Run the shell command in OS. system.

6. OS. sep can replace the path delimiter specified by the operating system.

7. The OS. linesep string indicates the row Terminator used by the current platform.

8. The OS. path. split () function returns the directory name and file name of a path.

9. The OS. path. isfile () and OS. path. isdir () functions verify whether the given path is a file or a directory.

10. OS. path.Exists() The function is used to check whether the given path actually exists.

11. OS. path. abspath (name): Obtain the absolute path.

12. OS. path. normpath (path): standard path string format

13. OS. path. getsize (name): Get the file size. If the name is a directory, return 0L

14. OS. path. splitext (): separates file names and extensions

15. OS. path. join (path, name): Connection directory and file name or directory

16. OS. path. basename (path): returns the file name.

17. OS. path. dirname (path): returns the file path.

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.