Python - os.popen 和 subprocess.Popen 有什么区别?
Python - os.popen 和 subprocess.Popen 有什么区别?
Python - what is difference in os.popen and subprocess.Popen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
os
进程功能被认为已过时。subprocess
模块是在 Python 2.4 中引入的,作为与子流程相关的几个旧模块和功能的统一、更强大的替代品。它们列于此处:os.system
os.spawn*
os.popen*
popen2.*
命令。*
os.popen
code> 在 Python 2.6 中已弃用(但有趣的是,它在 Python 3 中并未弃用,其中 它是通过subprocess.Popen
实现的)。文档中有一段关于 如何用subprocess.Popen
替换它。The
os
process functionality is considered obsolete. Thesubprocess
module was introduced in Python 2.4 as a unified, more powerful replacement for several older modules and functions related to subprocesses. They are listed here:os.system
os.spawn*
os.popen*
popen2.*
commands.*
os.popen
was deprecated in Python 2.6 (but, interestingly, it is not deprecated in Python 3, where it is implemented in terms ofsubprocess.Popen
). There is a paragraph in the documentation on how to replace it withsubprocess.Popen
.