What is the result of % in Python?

前端 未结 19 2098
粉色の甜心
粉色の甜心 2020-11-22 00:57

What does the % in a calculation? I can\'t seem to work out what it does.

Does it work out a percent of the calculation for example: 4 % 2

19条回答
  •  情书的邮戳
    2020-11-22 01:23

    It's a modulo operation, except when it's an old-fashioned C-style string formatting operator, not a modulo operation. See here for details. You'll see a lot of this in existing code.

提交回复
热议问题