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 8及之后的版本才可以使用假如我们有一些有外部IP的Laravel外部的测试网站,但是只想给自己访问。我是这么做的提供参考

docker, tinkerwell, tinker, laravel

Tinkerwell与docker环境运用

其实我最近不用Tinkerwell了,因为老是要我花钱更新。要测试直接ssh 主机不就搞定啦不是?