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 containers及docker images的命令

有时在自己的环境中试了一堆container或是images,如何全部移掉系统中所有的images及container 呢?这些命令提供给大家参考..

fastapi,haproxy

HAProxy与fastapi

HAProxy可以透过acl的定义来决定request要导向那台Backend,本文就来介绍本站的一些设置吧在这里透过path_beg的acl,让送来的request导向其他的服务,而不是域名所指定的后端。

ffmpeg

用ffmpeg列出MacOS支持的webcam及mic

这里日志如何在MacOS抓到capture devices