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

需要登入才可留言!

类似文章


laravel

Laravel上的表单方法欺骗

为何Laravel需要有Form Method Spoofing呢? 因为HTML表单并不支持PUT、PATCH及DELETE等动作,因此在Laravel上 在提交HTML表单送出时,我们需要透过一个隐藏的_method输入栏,作为HTTP的请求发送。

docker,laravel

用Docker创建Lravel开发环境超简单

Laravel 5.5系统环境您准备好了吗? laravel/framework 5.5.x-dev requires php >=7.0 -> your PHP version (5.6.30) does not satisfy that requirement. 这篇文章描述如何使用Docker创建Laravel的开发环境。 有了简单到爆炸的D-Laravel简易bash, 不要在说我无法创建Laravel的开发环境了。

linux,termux

如何在android手机背景播放mp4或webm

我有些Youtube下载下来的音档想要在背景播放,我知道如何做啦?