Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 423 Bytes

in.md

File metadata and controls

36 lines (24 loc) · 423 Bytes

判断元素是否在列表

nums = [1, 2, 3]

if 0 in nums:
    print("True")
else:
    print("False")

判断子字符串是否在文本中

sentence = "我爱天安门"

if "天安门" in sentence:
    print("true")
else:
    print("false")

判断字典中是否含有某元素

data = {"name": "li", "age": 3}

if 'age' in data:
    print("True")

else:
    print("False")