Home  >  Article  >  Backend Development  >  How to download os library in python

How to download os library in python

(*-*)浩
(*-*)浩Original
2019-08-01 15:04:3810813browse

The os library provides general, basic operating system interaction functions

How to download os library in python

The os library is a Python standard library that contains hundreds of Functions, commonly used include path operations, process management, environment parameters, etc.

The os module contains common operating system functions and is independent of the specific platform. The following lists commonly used commands (recommended learning: Python video tutorial)

1. os.name——Determine the platform currently being used, Windows returns 'nt'; Linux returns 'posix'

2. os.getcwd()——Get the current working directory.

3. os.listdir()——Specify all file and directory names in all directories.

4. os.remove()——Delete the specified file

5. os.rmdir()——Delete the specified directory

6. os.mkdir()— —Create a directory

Note:This can only create one layer. If you want to create it recursively, you can use: os.makedirs()

7. os.path.isfile() ——Determine whether the specified object is a file. Returns True, otherwise False

8. os.path.isdir() - Determines whether the specified object is a directory. Is True, otherwise False.

9. os.path.exists() - Check whether the specified object exists. Is True, otherwise False.

10. os.path.split()——Returns the directory and file name of the path.

Here we just separate the front and back parts. Just look for the last '/'.

For more Python related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to download os library in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn