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

需要登入才可留言!

类似文章


ubuntu, resolv.conf

如何调整ubuntu的/etc/resolv.conf设置

在CentOS的系统,通常我都直接改/etc/resolv.conf, 结果这次要改Ubuntu时上面确写著.. 「不要手动变更这个档,不然就把你的手砍掉」, 哦,翻错了吗?,# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN 所以Goolge一下就找到步骤了..

laravel

Laravel上的jenkins CI Server pipeline基本运用教程

您想透过docker创建持续集成及交付的CI Server给Laravel使用吗? 在CI Server上运行laravel dusk及phpunit轻松搞定自动化测试,及相关日志。 看完本篇或许您会发现CI/CD有多简单。 我指基本的运用。

fpm

在container内重启php-fpm

在container内重启php-fpm