python中求余数

>>> 5 % 0
Traceback (most recent call last):
  File "<pyshell#354>", line 1, in <module>
    5 % 0
ZeroDivisionError: integer division or modulo by zero
>>> 5 % 1
0
>>> 5 % 2
1
>>> 5 % 3
2
>>> 5 % 4
1
>>> 5 % 5
0
>>> 5 % 6
5
>>> 5 % 7
5
>>> 5 % 8
5
>>> 7 % 8
7
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14151069.html