当我在下面运行此代码时,它不是给我的,还是错

发布于 2025-02-06 10:43:33 字数 1399 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

向日葵 2025-02-13 10:43:33

正如其他人指出的那样,您需要对结果做一些事情。您可以将其保存到一个变量中:

var = 9 in some

或直接使用以下方式打印:

print(9 in some)

As others have pointed out, you need to do something with the result. You can save it into a variable with:

var = 9 in some

or print it directly with:

print(9 in some)
风苍溪 2025-02-13 10:43:33

di 返回true/false:

[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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文