- 整理的一些符號(前三個在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), Falseprint (False and True), Falseprint (1 == 1 and 2 == 1), Falseprint ("test" == "test"), Trueprint (1 == 1 or 2 != 1), Trueprint (True and 1 == 1), Trueprint (False and 0 != 0), Falseprint (True or 1 == 1), Trueprint ("test" == "testing"), Falseprint (1 != 0 and 2 == 1), Falseprint ("test" != "testing"), Trueprint ("test" == 1), Falseprint not (True and False), Trueprint not (1 == 1 and 0 != 1), Falseprint not (10 == 1 or 1000 == 1000), Falseprint not (1 != 10 or 3 == 4), Falseprint not ("testing" == "testing" and "Zed" == "Cool Guy"), Trueprint not (1 == 1 and not ("testing" == 1 or 1 == 0)), Falseprint not ("chunky" == "bacon" and not (3 == 4 or 3 == 3)), Trueprint (3 == 3 and not ("testing" == "testing" or "Python" == "Fun")), Falseprint "test" and "test" #輸出test,布爾操作符and和or會輸出操作符兩側的內容,而不是True和Falseprint "test" or "test"print not ("test" and "test")
View Code
False FalseFalse FalseFalse FalseTrue TrueTrue TrueTrue TrueFalse FalseTrue TrueFalse FalseFalse FalseTrue TrueFalse FalseTrue TrueFalse FalseFalse FalseFalse FalseTrue TrueFalse FalseTrue TrueFalse FalsetesttestFalse
注意"test" and "test" = "test",而不是1。or也是如此