在Python 3.x中,不允许将下限和模数运算符(分别为//和%)用于复数。但是,这些操作是在Python 2.7.x中为复数定义的
>>> x=9+2j >>> y=2+1j >>> x%y Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> x%y TypeError: can't mod complex numbers.
>>> x=9+2j >>> y=2+1j >>> x%y (1-2j)
复数操作数的模数返回其底数乘以分母
>>> x-(x//y)*y (1-2j)