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 次瀏覽

開啟你的 事業

透過完成課程獲得認證

現在開始
廣告