什么是3%4的Python?

jhe*_*aly -7 python

什么是3%4的Python?即我不知道结果如果:

  1. 余数是一个分数(而操作数是非分数)
  2. 第一个操作数<第二个操作数

Jon*_*age 6

%符号是模数运算符.一个简单的例子:

C:\Users\jon>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win
Type "help", "copyright", "credits" or "license" for more information.
>>> 3%4
3
>>> 4%3
1
>>> 4.5%3
1.5
>>> 4%3.5
0.5
Run Code Online (Sandbox Code Playgroud)