由此可见,python3中幂指数计算的优先级要高于单目运算符高,不确定的时候需要括号保险点!
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 2**2
4
>>> -3**2
-9
>>> (-3)**2
9
由此可见,python3中幂指数计算的优先级要高于单目运算符高,不确定的时候需要括号保险点!
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 2**2
4
>>> -3**2
-9
>>> (-3)**2
9