day-4 可变参数

 1 def send_report(*args):# 可变参数,参数组
 2     print(args)
 3 # *args不是必填参数,不限制参数个数,传递多个参数时,放在一个元组里面
 4 send_report()
 5 send_report(1)
 6 send_report(1,2,3)
 7 
 8 def send_mail(**kwargs):# 关键字参数,不是必填参数,返回一个字典,参参数时必须是name='xiaohei'这种方式
 9     print(kwargs)
10 
11 send_mail()
12 send_mail(1)#报错
13 send_mail(name='xiaohei',age='18')
14 
15 # 关键字参数后面不能再跟位置参数

 

posted @ 2019-10-29 17:08  维特布朗尼  阅读(82)  评论(0编辑  收藏  举报