Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of subprocess module in python

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "what is the use of the subprocess module in python", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and learn the article "what is the use of the subprocess module in python".

Description

1. Subprocess is a new module added to Python that allows new processes to be generated and connected to their input/output/error pipes.

And get their return (status) codes.

2. The purpose of this module is to replace several old modules and methods.

Common functions in subprocess module

Function describes the new functions in subprocess.run () Python 3.5. Executes the specified command and waits for the command to complete and returns an instance of the CompletedProcess class that contains the execution results. Subprocess.call () executes the specified command and returns the command execution status, which is similar to os.system (cmd). A new function in subprocess.check_call () Python 2.5. Executes the specified command and returns a status code if it is successful, otherwise an exception is thrown. Its function is equivalent to subprocess.run (..., check=True). A new function in subprocess.check_output () Python 2.7. Executes the specified command and returns the command execution result if the execution status code is 0, otherwise an exception is thrown. Subprocess.getoutput (cmd) receives a command in string format, executes the command, and returns the execution result, which is similar to os.popen (cmd). Read () and commands.getoutput (cmd). Subprocess.getstatusoutput (cmd) executes the cmd command and returns a tuple (command execution status, command execution result output), which functions similar to commands.getstatusoutput (). The above is all the content of the article "what is the use of subprocess module in python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report