[In]: 3 in list([1,2,35])
[Out]: False
[In]: 3 in list([1,2,3,5])
[Out]: True
从文档中返回:
“ 和 in in 在中的运算符。 如果X是S的成员,则为true,否则为错误。 x不在s返回中 x在s中的否定。所有内置序列和集合类型支持 这是该字典,在测试中是否词典 具有给定的键。” docs
It does return a TRUE/FALSE:
[In]: 3 in list([1,2,35])
[Out]: False
[In]: 3 in list([1,2,3,5])
[Out]: True
From the documentation:
"The operators in and not in test for membership. x in s evaluates to True if x is a member of s, and False otherwise. x not in s returns the negation of x in s. All built-in sequences and set types support this as well as dictionary, for which in tests whether the dictionary has a given key." docs
发布评论
评论(2)
正如其他人指出的那样,您需要对结果做一些事情。您可以将其保存到一个变量中:
或直接使用以下方式打印:
As others have pointed out, you need to do something with the result. You can save it into a variable with:
or print it directly with:
它 di 返回true/false:
从文档中返回:
It does return a TRUE/FALSE:
From the documentation: