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

需要登入才可留言!

类似文章


如何更新D-Laravel内的Laravel installer.

Laravel 5.5推出了,如何更新D-Laravel内的image使用最新的laravel installer呢? 这篇文章教大家如何更新自己在dlaravel内的Laravel installer,并且commit 变更过的image.

docker

[必学]在docker swarm环境必学iptabels的使用

首先Docker在Linux的环境下,Docker使用iptables规则来提供网络隔离。然而在Docker swarm mode的环境下,我们是没辨法把连接埠开在host的127.0.0.1下的,这时便可透过iptables中的DOCKER-USER chain来自定义规则罗 。

linux,mac

MacOS或Linux上的密码生成器

有时侯我们需要生成一个随机的密码,但是想破头不知用什么好? 这里提供一个简单的bash让我们轻易的生成一组密码在终端机上。