# Python CodeRecipe|isの使い方

Home Python Keywords

# isの例1

Check if two objects are the same object:

    x = ["apple", "banana", "cherry"]y = xprint(x is y)

# isの定義及び使い方

is関数を使用して、if2をテストします。 変数は同じオブジェクトを参照します。 2つのオブジェクトが同じ場合、テストはTrueを返します。 2つの引数が同じオブジェクトでない場合、2つの引数が同じであってもFalseが返されます。 オブジェクトは100%等しくなります。 ==演算子を使用して、2つの変数が等しいかどうかをテストします。

# isの例2

Test two objects that are equal, but not the same object:

    x = ["apple", "banana", "cherry"]
    y = ["apple", "banana", "cherry"]print(x is y)

Home Python Keywords