python 实现return返回多个值
作者:JokerJason 时间:2022-10-12 17:23:37
函数的return 语句只能返回一个值,可以是任何类型。
因此,我们可以“返回一个 tuple类型,来间接达到返回多个值 ”。
例: x 除以 y 的余数与商的函数
def F1 ( x, y ):
a = x % y
b = (x-a) / y
return ( a,b ) # 也可以写作 return a, b
(c, d )= F1( 9, 4) # 也可以写作 c , d = F1 ( 9, 4 )
print c ,d
结果显示: 1, 2
来源:http://www.cnblogs.com/jokerjason
标签:python,return,返回值
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
PHP中include和require的使用详解
2023-10-22 03:57:03
python shapely.geometry.polygon任意两个四边形的IOU计算实例
2021-09-23 03:19:46
Python NumPy灰度图像的压缩原理讲解
2021-02-16 02:46:33
Python itertools模块详解
2021-06-11 16:33:03
前端面试之vue2和vue3的区别有哪些
2024-04-28 10:54:38
Python可视化神器pyecharts之绘制箱形图
2021-08-04 03:40:53
![](https://img.aspxhome.com/file/2023/6/102956_0s.png)
条件CSS的使用[译]
2009-03-12 12:23:00
![](https://img.aspxhome.com/file/UploadPic/20093/12/01-51s.jpg)
PHP基于openssl实现非对称加密代码实例
2023-07-13 05:38:22
MySQL8.0.23安装超详细教程
2024-01-26 05:06:18
![](https://img.aspxhome.com/file/2023/0/78200_0s.png)
python asyncio 协程库的使用
2022-09-13 13:28:16
Python numpy中矩阵的基本用法汇总
2021-10-23 06:37:26
![](https://img.aspxhome.com/file/2023/6/114526_0s.png)
Python用threading实现多线程详解
2021-06-19 13:35:48
php下常用表单验证的正则表达式
2024-05-03 15:35:08
解决Can't locate ExtUtils/MakeMaker.pm in @INC报错
2024-01-22 20:46:49
es6中some和every方法使用简单示例
2024-06-05 09:10:39
![](https://img.aspxhome.com/file/2023/0/123390_0s.png)
面试中老生常谈的MySQL问答集锦夯实基础
2024-01-16 18:07:23
![](https://img.aspxhome.com/file/2023/9/67589_0s.jpg)
Mysql锁内部实现机制之C源码解析
2024-01-12 21:13:25
![](https://img.aspxhome.com/file/2023/4/70454_0s.png)
vue 开发一个按钮组件的示例代码
2024-04-30 10:27:40
Django如何使用redis作为缓存
2022-12-30 19:19:20
sqoop如何指定pg库的模式(方法详解)
2022-09-30 02:52:47
![](https://img.aspxhome.com/file/2023/8/120508_0s.png)