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)