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)