# 没返回值 返回 none
# def test1():
# mg = 'hello world'
# print(mg)
# 函数
# def test2():
# mg = 'hello!'
# print(mg)
# return mg
#
# def test3():
# mg = 'hello!'
# print(mg)
# return 1,2,3,'a',['lei'],{'name':'alex'},None
#
# t1 = test1() # hello world
# t2 = test2() # hello!
# t3 = test3() # hello!
# print(t1) # None
# print(t2) # hello!
# print(t3) # (1, 2, 3, 'a', ['lei'], {'name': 'alex'}, None)
# 总结
# 返回值数 = 0 返回 None
# 返回值数 = 1 返回 object
# 返回值数 > 1 返回 tuple
# 位置参数
# def test(x,y,z):
# print(x)
# print(y)
# print(z)
# 必须一一对应 缺一不行多一不行
# test(1,3,2)
# 关键字参数 无须一一对应 缺一不行多一不行
# test(y = 1,x = 3,z = 2)
# 位置参数必须在关键词参数左边 且不能重复
# test(1,y=2,3) # 报错
# test(1,2,y=3) # 不报错
# 默认参数
# def handle(x,type='mysql'):
# print(x)
# print(type)
#
# handle('hello','sqlite')
# 参数组 **字典 *列表
# def test(x,*args):
# print(x)
# print(args)
# test(1,2,3,4,5)
# 1
# (2, 3, 4, 5)
# test(1,['x','y','z'])
# 1
# (['x', 'y', 'z'],)
# test(1,*['x','y','z'])
# 1
# ('x', 'y', 'z')
# def test(x,**kwargs):
# print(x)
# print(kwargs)
# test(1,y=2,z=3)
# 1
# {'y': 2, 'z': 3}
# test(1,y=2,z=3,z=3) # 会报错 一个参数不能传两值
# def test(x,*args,**kwargs):
# print(x)
# print(args)
# print(kwargs)
# test(1,1,2,3,x=1,y=2,z=3) # 报错
# test(1,2,3,4,y=2,z=3)
# 1
# (2, 3, 4)
# {'y': 2, 'z': 3}
# test(1,*[1,23,4],**{'x':1}) # 报错 因为 x 重复了
# test(1,*[1,23,4],**{'y':1})
# 1
# (1, 23, 4)
# {'y': 1}
# 函数好处
# 1.代码重用
# 2.保持一致性,易于维护
# 3.可扩展性