What is the applicable way of python commands module?
This article is to share with you about the application of the python commands module. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Application of commands module
The commands module is the built-in module of python. It has three functions, which can be seen using help (commands).
FUNCTIONS getoutput (cmd) Return output (stdout or stderr) of executing cmd in a shell. Getstatus (file) Return output of "ls-ld" in a string. Getstatusoutput (cmd) Return (status,output) of executing cmd in a shell.1, commands.getstatusoutput (cmd) returns a tuple (status,output)
The return status of the shell command represented by status, and if successful, 0 is the result of the output of shell
> import commands > status, output = commands.getstatusoutput ("ls") > > print status0 > print outputatom:bookstorecookie.py~2, return the result of ls-ld file execution commands.getstatus (file) 3, judge the output of Shell command commands.getoutput (cmd) > print commands.getoutput ("ls") atom:bookstorecookie.py~commands method
The commands module is the built-in module of Python, and it has three main functions:
Function description getoutput (cmd) Return output (stdout or stderr) of executing cmd in a shell.getstatus (file) Return output of "ls-ld file" in a string.getstatusoutput (cmd) Return (status, output) of executing cmd in a shell. Thank you for reading! This is the end of the article on "what is the application of the python commands module?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!