Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Python インタープリターで次を実行します。
>>> foo = 10 >>> dir(foo) == dir(10) True >>> dir(foo) is dir(10) False >>>
どうしてこれなの?
is2 つの引数が同じオブジェクトを参照していることを==確認し、2 つの引数が同じ値を持っていることを確認します。 との両方に同じデータを含む をdir()返しますが、2 つの実際のインスタンスは異なります。listfoo10list
is
==
dir()
list
foo
10