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)