位置传参
def happy_birthday(name,age):
print('祝'+name+'生日快乐')
print(str(age)+'岁生日快乐')
#调用
happy_birthday('卷字节','18')
关键字传参
def happy_birthday(name,age):
print('祝'+name+'生日快乐')
print(str(age)+'岁生日快乐')
#关键字传参
happy_birthday(age=18,name='jzj')
happy_birthday('cmm',age=18)
#happy_birthday(name='cmm',18) SyntaxError: positional argument follows keyword argument
#如果既有位置传参由于关键字传参
#位置传参在前,关键字传参在后
(仅供参考)
Comments NOTHING