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

需要登入才可留言!

类似文章


ssl,haproxy,certbot

完美SSL证书自动化更新环境(HAProxy加certbot)

HAProxy的重载速度很快,跟本感觉不出有重启,所有证书都给HAProxy处理真的很方便。主机环境需求,请确认您已有下面两个命令(Ubuntu怎么装? apt-get install -y haproxy cerbot,我猜的,如果不是请自行Google)

laravel

@dump介绍,Laravel 5.6.8新功能

在Laravel 5.6的directive多了一个新功能叫@dump了 让我们来看看他有多cool。

Raspberry

Raspberry播放midi档

Raspberry播放midi音乐