[Python] python中一个函数返回多个值的方法 →→→→→进入此内容的聊天室

来自 , 2019-08-22, 写在 Python, 查看 138 次.
URL http://www.code666.cn/view/e2a08f2e
  1. #让函数返回元组
  2. >>> def myfunction(a):
  3.  return (a+1,a*2,a*a)
  4. >>> print myfunction(3)
  5. (4, 6, 9)
  6.  
  7. #同时你也通过元组接收返回值,并存放在不同的变量里
  8. >>> (a,b,c) = myfunction(3)
  9. >>> print b
  10. 6
  11. >>> print c
  12. 9

回复 "python中一个函数返回多个值的方法"

这儿你可以回复上面这条便签

captcha