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

需要登入才可留言!

类似文章


dlaravel

D-Laravel上的.env.example档说明

本文说明关於D-Laravel上的.env设置 MYSQL_ROOT_PASSWORD=secret LARAVEL_INSTALLER='container' DOCKER_SERVICES='docker-compose.yml service/redis.yml'

MacOS

MacOS上重启sshd服务

纪录我如何在MacOS上重启sshd服务。

cwebp,bash

我如何用bash优化网站图档,透过cwebp转图

我的网站中有大量背景图在同一个页面中,下载下来太大罗,需要瘦身,这cwebp工具不错。在ubunut的环境apt install webp就可以安装罗。