Python divmod() 函数

时间:2020-07-26 15:09:49   收藏:0   阅读:69

python divmod() 函数把除数和余数运算结果结合起来,返回一个包含商和余数的元组(a // b, a % b)。

在 python 2.3 版本之前不允许处理复数。每组词 www.cgewang.com

函数语法

divmod(a, b)

参数说明:

实例

>>>divmod(7, 2) (3, 1) >>> divmod(8, 2) (4, 0) >>> divmod(1+2j,1+0.5j) ((1+0j), 1.5j)
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!