关键字:return
没有返回值的叫过程
def test1(): msg="我是一个过程" print(msg)
有return的叫函数
def test02(): msg="我是函数,有返回值" print(msg) return msg
关于返回的值: 定义的函数可以返回多个值,组合成元组def test03(): msg=‘我要返回多个值‘ print(msg) return msg,"hello xiaozhu",[1,2,3,4,5],{‘name‘:‘zhou‘,‘age‘:18} t3=test03()
print(‘test03的结果:‘+‘\n‘+‘\t‘+str(t3))
运行结果:
原文地址:https://www.cnblogs.com/Hanro-Z/p/9249860.html
时间: 2024-11-07 19:34:29