by Devin Yang

建立于: 6年前 ( 更新: 6年前 )

最简化版本的Python系统命令运行范本

#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
from subprocess import Popen, PIPE, STDOUT
#运行的命令
command='ls -l'.split()
proc=Popen(command , stdout=PIPE,stderr=PIPE, universal_newlines=True);
output, error = proc.communicate()

#显示运行结果
if(proc.poll()==0):
     print(output)
else:
     print("{} Error\n".format(error))


 

Tags:

Devin Yang

文章内容无法一一说明,如果您有什么不了解处,欢印提问哦:)

No Comment

Post your comment

需要登入才可留言!

类似文章


git

我如何删除,我GitHub上的远程分支

我如何删除,我GitHub上的远程分支。 首先,可先用命令查看origin git remote -v 这时可能显示如下: origin https://github.com/DevinY/dlaravel.git (fetch) origin https://github.com/DevinY/dlaravel.git (push)

linux

加载.env的环境变量到系统上

加载.env的环境变量到系统上

linux

如何检查apache加载并激活了那些modules?

如何检查apache加载并激活了那些modules?