python—day03_函数

1,参数

普通参数

# ######### 定义函数 ######### 
# name 叫做函数func的形式参数,简称:形参
def func(name):
    print(name)
    
# ######### 执行函数 ######### 
#  'wupeiqi' 叫做函数func的实际参数,简称:实参
func('hello world')

默认参数

def func(name, age = 18):
    print("%s:%s" % (name, age))


func('gongf', 25)
func('xiaomin')

动态参数

def func(*args):
    print(args)

func(11,22,33,44,55)

li = [11,22,33,4,55]
func(*li)

原文地址:https://www.cnblogs.com/gongfan1992/p/7872078.html