当前位置 : 主页 > 编程语言 > python >

Python-函数(任意实参)

来源:互联网 收集:自由互联 发布时间:2022-06-15
""" 关键字任意实参,练习 """ # **kwargs对应函数会创建一个空字典用来存储多的键值对;*args是用来接收任意位置实参 def cars_info(maker, model, **kwargs): kwargs['maker_name'] = maker kwargs['model_name']
"""
关键字任意实参,练习
"""


# **kwargs对应函数会创建一个空字典用来存储多的键值对;*args是用来接收任意位置实参

def cars_info(maker, model, **kwargs):
kwargs['maker_name'] = maker
kwargs['model_name'] = model
return kwargs


def pets_info(pet_name, *args):
print('pet_name:' + pet_name)
print('pet_info:')
for info in args:
print(info)


car_info = cars_info('Tom', 'BWM', color='blue', price=100000)
print(car_info)
pets_info('haha', 'nice', 'stoner')
print(pets_info)
# 打印顺序有点问题
上一篇:【原创】医鹿APP九价HPV数据抓包分析
下一篇:没有了
网友评论