Common functions of the OS module in Python: pythonos Module
This document references ------ concise Python tutorial
OSIs an important module of python. Before use, you must:Import OS
Common functions are as follows:
(1)OS. name, Returns the platform in use.
(2)OS. getcwd (), Returns the current working directory.
(3)OS. path. exists ()To check whether the given path actually exists.
(4)OS. path. isfile ()To check whether the given path is a file.
(5)OS. path. isdir ()To check whether the given path is a directory.
(6)OS. path. split ()Returns the directory name and file name of a path.
(7)OS. getenv ()To read environment variables.
(8)OS. putenv ()To set environment variables.
(9)OS. listdir ()Specifies the names of all the file boxes in the directory.
(10)OS. remove ()To delete an object.
(11)OS. system ()To run shell commands.
(12)OS. sep, The delimiter in this operating system.
(13)OS. linesepIn this operating system, the line break is '\ r \ n' for windows,' \ n' for linux, and '\ R' for mac'
The result of calling the content in the OS module in the python function is undefined.
Your problem is very strange.
Why is there no function in the ospy module in python?
In python
>>> Import OS
>>> OS. listdir. _ module __
'Posix'
We can see that listdir is defined in module posix.
The OS module imports the posix module.