python 函数返回值(总结)

  关键字: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))

运行结果:

  


猜你喜欢

转载自www.cnblogs.com/Hanro-Z/p/9249860.html