搜索
您的当前位置:首页正文

Python for Linux and Unix System Administration -3 function

来源:易榕旅网
wes@wes:~/Documents/python/ch1$ cat python-5
#!/usr/bin/env python
def pyfunc():
        print("Hello Function!")
for i in range(5):
        pyfunc()

wes@wes:~/Documents/python/ch1$ python python-5
Hello Function!
Hello Function!
Hello Function!
Hello Function!
Hello Function!
wes@wes:~/Documents/python/ch1$ cat shell-5
#!/bin/bash

function shfunc()
{
        printf "Hello function\n"
}
for ((i=0; i<5; i++))
        do
                shfunc
done

wes@wes:~/Documents/python/ch1$ bash shell-5
Hello function
Hello function
Hello function
Hello function
Hello function
wes@wes:~/Documents/python/ch1$ cat python-6
#!/usr/bin/env python
# A System information gathering script
import subprocess

# Command1
def uname_func():
        uname = "uname"
        uname_arg = "-a"
        print("Gathering system informaiton with %s command:\n" %uname)
      

因篇幅问题不能全部显示,请点此查看更多更全内容

Top