by Devin Yang

建立於: 6年前 ( 更新: 6年前 )

最簡化版本的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

需要登入才可留言!

類似的文章


dlaravel

D-Laravel測試域名*.dev變更為*.test

由於Google Chrome 63會強制轉換*.dev的域名為https了,D-Laravel新版的域名變更為*.test。 本文說明更新的方式。

pip3 install face_recognition

在Raspberry Pi 3上執行臉部辨識軟體

vpn,cli,macos

我如何在MacOS上用命令列撥VPN

我自己會有用MacOS在命令列撥VPN的需求,在這提供我的別名,設定方式