0
のマッチング、私は次のように簡単なコードを使用してみました:Pythonの文字列は、文字列のリストにいくつかの文字列を排除しようとしているときに
>>> s = ['a b', 'c d', 'e f', 'g h']
>>> for i in s:
... if i is not 'e f':
... print(i)
...
a b
c d
e f # this should not get printed, right?
g h
をし、私は基本的な動作を理解することができませんか。 説明できますか?以下のように論理的であると思われるからです。
>>> if 'a b' is not 'a b':
... True
... else:
... False
...
False
>>> s = ['a', 'c', 'e', 'g']
>>> for i in s:
... if i is not 'e':
... print(i)
...
a
c
g
は特別扱いのスペースですか?私は何が欠けていますか?