python符号的优先

运算符描述
lambda Lambda表达式
or 布尔“或”
and 布尔“与”
not x 布尔“非”
in,not in 成员测试
is,is not 同一性测试
<,<=,>,>=,!=,== 比较
| 按位或
^ 按位异或
& 按位与
<<,>> 移位
+,- 加法与减法
*,/,% 乘法、除法与取余
+x,-x 正负号
~x 按位翻转
** 指数
x.attribute 属性参考
x[index] 下标
x[index:index] 寻址段
f(arguments...) 函数调用
(experession,...) 绑定或元组显示
[expression,...] 列表显示
{key:datum,...} 字典显示
'expression,...' 字符串转换

 

优先级是最小面最优先、从下往上数、如果迩还不信、迩可以运行一下下面的小代码来证实

 

true = True
false = False
if not false or true:
print "yes"
else:
print "no"


##
#ture or false => true
#false or false => false
#ture or ture => true

##如果是先not后or、那么一定会返回true、也就是yes
##如果是先or后not、那么一定会返回false、也就是no、
##但结果输出了yes、证明是先not后or



posted @ 2012-01-10 18:25  klobodnf  阅读(399)  评论(0编辑  收藏  举报