gpt4 book ai didi

python - (a not in b) 和 (not a in b) 之间的区别。 Python

转载 作者:太空宇宙 更新时间:2023-11-03 12:39:28 26 4
gpt4 key购买 nike

<分区>

嗨,有人可以阐明在 Python 中使用“in”运算符的机制吗。

我现在正在处理以下示例:

print ('a' not in ['a', 'b'])  # outputs False
print (not 'a' in ['a', 'b']) # outputs False -- how ???

print ('c' not in ['a', 'b']) # outputs True
print (not 'c' in ['a', 'b']) # outputs True


print (not 'a') # outputs False
# ok is so then...
print (not 'a' in ['b', False]) # outputs True --- why ???

我现在想知道怎么会这样。如果有人知道,请分享您的知识。谢谢 =)

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com