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

需要登入才可留言!

类似文章


php

我的拼装车LaNativeRoute

我虽然很喜欢Laravel,Laravel有很多特点都非常棒,像是Eloquent ORM、Model、Blade temple我都非常喜欢, 但是说真的,他真的非常肥大,导致跑起步来好像有点慢,所以我就试著使用我自己想要的方式 抽取我要的功能,拼装出这个自制的框微型架,接近Plain PHP,我想懂php的人都可以上手吧。

MacOS

MacOS上重启sshd服务

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

dlaravel

D-laravel已添加建议的opcache.ini设置了

最新版本的D-Laravel已添加opcache的建议设置了。 激活方式非常简单,请在D-Laravel目录下运行即可。