学习目的:
1)函数调用
2)subprocess模块的使用
subprocess.call([命令,参数])
代码如下:
[root@oracle ~]# more pysysinfo_func.py #! /usr/bin/env python import subprocess def uname_func(): uname="uname" uname_arg="-a" print "Gathering system information with %s command:\n" %uname subprocess.call([uname,uname_arg]) def disk_func(): diskspace="df" diskspace_arg="-h" print "Gathering diskspace information %s command :\n" %diskspace subprocess.call([diskspace,diskspace_arg]) def main(): uname_func() disk_func() main()
本文出自 “帝心禅影” 博客,请务必保留此出处http://yedee.blog.51cto.com/513852/1550948
原文地址:http://yedee.blog.51cto.com/513852/1550948