day14 Python函数

函数def,严格来讲有个return返回值

过程就是没有return返回值的函数

#过程
def test01():
    msg = 'liuhaoran'
    print(msg)
#函数
def test02():
    msg = 'liuxueting'
    print(msg)
    return msg,1,2,['charon'],{"name":"pluto"}
t1 = test01()
t2 = test02()
print(t1)
print(t2)


结果:
liuhaoran
liuxueting
None    #没有返回值就返回个None
('liuxueting', 1, 2, ['charon'], {'name': 'pluto'})  #返回一个元祖

 总结:

返回值=0,返回None

返回值=1,返回object

返回值>1,返回tuple 

猜你喜欢

转载自www.cnblogs.com/charon2/p/10371145.html