ITeye博客

python执行shell命令的四种方法

f002489 · 2016-12-28 22:36 · Python -- Django · 编程语言 · Python · Markdown

#!/usr/bin/env python

-- coding: utf-8 --

import os
import platform
import subprocess
import commands
def subproc():
print "系统进程数:"
subprocess.call("ps -ef|wc -l",shell=True)
def os_popen():
print "IP地址:"
os1 = platform.system()
if os1 == "Linux":
print os1
ip1 =os.popen("/sbin/ifconfig eth0|grep 'inet addr'").read().strip().split(":").split()
print "\033

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。