【python爬蟲】 -第六天

# print(True and True)

# # true

# 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(1 == 1 and not ("testing" == 1 or 1 == 0))

# true

print(3 == 3 and not ("testing" == "testing" or "Python" == "Fun"))

# false


這一節(jié)課比較重要的是記住關(guān)系運(yùn)算符的表示方法:


還有邏輯運(yùn)算符的推算,這個(gè)在高中數(shù)學(xué)有學(xué)過類似的關(guān)系判定,有一定基礎(chǔ)較好理解和記憶。

其中要特別記住的是,or這個(gè)邏輯運(yùn)算符,含義是or前面和后面只要有任意一個(gè)為true,or這個(gè)式子也就是true。

“非0即為真,非真即為假” ?是對(duì)not的口訣。

新的字符串知識(shí):

str.startswith(str1,start,end) ? ? ?str.endswith(str1,start,end)

括號(hào)里面start是索引數(shù)字,str1是字符串中的片段

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容