- 整理的一些符号(前三个在java和c中是不这样表达的,用&&、||、!表达)
- and
- or
- not
- != (not equal)
- == (equal)
- >= (greater-than-equal)
- <= (less-than-equal)
- True
- False
View Code
# _*_ coding:utf-8 _*_ print (True and False), False print (False and True), False print (1 == 1 and 2 == 1), False print ("test" == "test"), True print (1 == 1 or 2 != 1), True print (True and 1 == 1), True print (False and 0 != 0), False print (True or 1 == 1), True print ("test" == "testing"), False print (1 != 0 and 2 == 1), False print ("test" != "testing"), True print ("test" == 1), False print not (True and False), True print not (1 == 1 and 0 != 1), False print not (10 == 1 or 1000 == 1000), False print not (1 != 10 or 3 == 4), False print not ("testing" == "testing" and "Zed" == "Cool Guy"), True print not (1 == 1 and not ("testing" == 1 or 1 == 0)), False print not ("chunky" == "bacon" and not (3 == 4 or 3 == 3)), True print (3 == 3 and not ("testing" == "testing" or "Python" == "Fun")), False print "test" and "test" #输出test,布尔操作符and和or会输出操作符两侧的内容,而不是True和False print "test" or "test" print not ("test" and "test")
View Code
False False
False False
False False
True True
True True
True True
False False
True True
False False
False False
True True
False False
True True
False False
False False
False False
True True
False False
True True
False False
test
test
False
注意"test" and "test" = "test",而不是1。or也是如此