當前位置:首頁 » 編程語言 » python字元串notin

python字元串notin

發布時間: 2025-08-14 13:46:58

A. Python中關系運算符in,not in在字元串表達式和列表的使用時有什麼區別和注意點

Membership test operations

For container types such as list, tuple, set, frozenset, dict, or collections.deque, the expressionxinyis equivalent toany(xiseorx==eforeiny).

For the string and bytes types,xinyisTrueif and only ifxis a substring ofy. An equivalent test isy.find(x)!=-1. Empty strings are always considered to be a substring of any other string, so""in"abc"will returnTrue.

翻譯:

對容器類型,例如list、tuple、set、frozenset、dict或collections.deque,表達式x in y等價於any(x is e or x == e for e in y)。

對字元串和bytes類型,x in y為真當且僅當x是y的子串。等價測試為y.find(x) != -1。空字元串永遠被視作是其他任何字元串的子集,因此"" in "abc"將返回True。

熱點內容
機變酷卡編程 發布:2025-08-14 15:25:54 瀏覽:881
ftp亂碼上傳 發布:2025-08-14 15:25:52 瀏覽:728
sqlserver2008數據類型 發布:2025-08-14 15:25:03 瀏覽:718
魂斗羅歸來解壓縮 發布:2025-08-14 15:17:00 瀏覽:862
農村存儲 發布:2025-08-14 15:16:49 瀏覽:300
windows之間使用ftp傳輸 發布:2025-08-14 15:16:01 瀏覽:371
c語言寫的俄羅斯方塊 發布:2025-08-14 15:13:01 瀏覽:886
安卓怎麼跟別人合拍唱歌有自己聲音 發布:2025-08-14 14:57:41 瀏覽:984
java在線培訓系統 發布:2025-08-14 14:56:03 瀏覽:646
電腦怎麼卸載伺服器管理 發布:2025-08-14 14:37:57 瀏覽:504