Python 中的“not in”运算符的作用是什么?
在 Python 中,“in”和“not in”运算符称为成员运算符。其目的是检查某个对象是否是字符串、列表或元组等特定序列对象中的成员。“not in”运算符如果某个对象存在于序列中则返回 false,如果未找到则返回 true
>>> 'p' not in 'Tutorialspoint' False >>> 'c' not in 'Tutorialspoint' True >>> 10 not in range(0,5)
广告
在 Python 中,“in”和“not in”运算符称为成员运算符。其目的是检查某个对象是否是字符串、列表或元组等特定序列对象中的成员。“not in”运算符如果某个对象存在于序列中则返回 false,如果未找到则返回 true
>>> 'p' not in 'Tutorialspoint' False >>> 'c' not in 'Tutorialspoint' True >>> 10 not in range(0,5)