当前位置:首页 » 编程语言 » 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。

热点内容
python编译为dll 发布:2025-08-14 15:43:40 浏览:788
机变酷卡编程 发布: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