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)

更新时间:2020-02-26

259 次浏览

开启你的 事业

通过完成课程获得认证

现在开始
广告
© . All rights reserved.