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

需要登入才可留言!

类似文章


docker

如何简单的用Docker创建internet命令行的测速进程呢?

如何简单的用Docker创建internet命令行的测速进程呢? 这里我们使用python的进程speedtest-cli 会用Docker主要的用例,例如我想要在我的NAS内进行测速, 虽然我的NAS内有python,但没有pip命令,这时用Docker感觉上安全很多, 当然前题您的NAS需能跑Docker:)。 或者,我在MacOS的环境,我不想安装speedtest-cli到我的MacOS中。 这时用Docker简单的自建简单的运行环境还满不错的。

openai,flax,docker

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

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

docker,laravel,nfs

Docker在macOS上的NFS

D-laravel的nfs模式,在这篇文章您可以了解到,如何在macOS使用NFS+Docker。