Python in 的逻辑判断

python 中的in,要看你的目标是什么

1.字符串

>>> "in" in "indigo"
True
>>> "in" in "violet"
False
>>> "0" in "10"
True
>>> "1" in "10"
True

2. 数组

>>> "in" in ["in", "out"]
True
>>> "in" in ["indigo", "violet"]
False

3. 字典,是看key

>>> "in" in {"in": "out"}
True
>>> "in" in {"out": "in"}
False

http://www.waitingfy.com/archives/4591

4591

Leave a Reply

Name and Email Address are required fields.
Your email will not be published or shared with third parties.