标签:cat mat **kwargs format ike bsp 信号 name print
函数参数的调用和参数的排列顺序
def jieshao(name,age,*args,like=‘没有‘,**kwargs):
print(‘我叫{0},我{1}大‘.format(name,age))
if like==‘没有‘:
print(‘不好意思我没有兴趣爱好。‘)
else:
print(‘我的爱好是{0}‘.format(like))
for x in args:
print(x)
print(‘-‘*40)
for k,v in kwargs.items():#调用字典时要用items方法
print(k,‘^‘*10,v)
print(‘*‘*50)
jieshao(‘小蒋‘,16,‘sex‘,‘lan‘,‘eat‘,‘cat‘,cao=‘go‘,sex=‘women‘)
解包符号
def dingyi(*args):
print(‘X‘*40)
for n in args:
print(n)
print(‘^‘*50)
list = [‘gogo‘,798798,‘fk‘,‘tm‘]
dingyi(*list)#信号为解包符号
标签:cat mat **kwargs format ike bsp 信号 name print
原文地址:https://www.cnblogs.com/jjk-xiaoxuetu/p/10067758.html