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 build自己专用的php fpm image。

D-Laravel已提供了Build好的php image,如果需要自己调整及Build自己专用的Image相当简单。 一、首先在D-Laravel的录中,进入dockerfiles/fpm,选择您要Build的PHP版本,例如7.2。 命令如下...

docker

ubuntu上安装docker-compose

简单介绍我如何在ubuntu上安装docker-compose. 还满容易的。

openai,flax,docker

用容器跑OpenAI官方教程的Python(Flax)

如果您登录了openai的网站,可在此处看到官方的教程说明https://beta.openai.com/docs/quickstart/build-your-applicationAPI的KEY的申请,就在这页的下方就有按钮了+ Create new secret key本篇教您用Docker跑官方OpenAI运行环境。