divmod()属于python内置的一个数学运算函数,它用来计算两个数字的相除的商(x//y)和余数(x%y)

商和余数通过2元组的形式返回

当运算不满足数学规则时则报错。

>> help(divmod)
Help on built-in function divmod in module builtins:

divmod(x, y, /)
    Return the tuple (x//y, x%y).  Invariant: div*y + mod == x.

>>> divmod(9,2)
(4, 1)
>>> 

相关文章:

  • 2022-01-10
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2021-10-02
  • 2021-06-08
猜你喜欢
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-06
相关资源
相似解决方案