标签:img 形参 默认 实参 src code pytho turn name
#顺序传入参数
def show(name,age,sex,hobby):#形参
print("我叫:",name,"年龄:",age,"性别:",sex,"爱好:",hobby)
show("张三",18,"男","打球")#实参(实参与形参一一对应)
#关键词传入参数
def show(name,age,sex,hobby):#形参
print("我叫:",name,"年龄:",age,"性别:",sex,"爱好:",hobby)
show(name="张三",sex="男",age=19,hobby="打球") #实参关键词传入
#关键词传入参数
def show(name,age,sex,hobby="打0球"):#形参默认参数hobby
print("我叫:",name,"年龄:",age,"性别:",sex,"爱好:",hobby)
show(name="张三",sex="男",age=19) #实参
#不定长参数传入
def add(*ars):
sum1=0
for i in ars:
sum1=sum1+i
return sum1
print(add(32,32,43))
标签:img 形参 默认 实参 src code pytho turn name
原文地址:https://www.cnblogs.com/lma0702/p/11109378.html