代码点读机 / Python / divmod

divmod Python · 内置函数

同时算出商和模,返回 (商, 模) 的元组。

怎么用

divmod(被除数, 除数)

小例子

print(divmod(17, 5))

运行结果

(3, 2)

官方文档:https://docs.python.org/zh-cn/3/library/functions.html#divmod

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条