ly-chengwu 发表于 2020-3-7 17:37:34

not/and/or在下列运算中代表的什么意思?

not 1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9

zltzlt 发表于 2020-3-7 17:39:46

not 是取反,and 是逻辑与,or 是逻辑或

    not 1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9
==0 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9
==0 or 0 or 4 or 6 or 9
==4    # 短路求值

墨羽岚 发表于 2020-3-7 17:52:11

not取反,and与,or或
优先级:not>and>or(即判断顺序为not、and、or)
not 0就是非0(取1(True)),noti(一个非0数,正负都行)就是0;
and表示与,前后都不为0时取后面的数为结果;短路指前面的数为0时跳过后面数的判断,结果直接为0;
or表示或,前后只要有数不为0时取第一个不为0的数为结果;短路指第一个数不为0时跳过后面的数的判断,结果直接为第一个数。
页: [1]
查看完整版本: not/and/or在下列运算中代表的什么意思?