by Devin Yang

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

最简化版本的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

需要登入才可留言!

类似文章


php

Apache移除了Authorization Header问题

Apache移除了Authorization Header,在$_SERVER中看不到解法。

router,nat

我的居易防火墙NAT笔记

本篇日志我查到关於居易的NAT及DMZ相关说明,我用Goolge翻译播成中文再稍微调一下。居易的NAT有「连接埠重定向」、「开放连接埠」和 「DMZ 主机」。(There are Port Redirection, Open Ports, and DMZ Host.)

linux

ubuntu找不到add-apt-repository命令

ubuntu找不到add-apt-repository命令