# Python CodeRecipe|delの使い方
❮ Home ❮ Python Keywords
# delの例1
Delete an object:
class MyClass: name = "John"del myClassprint(myClass)
# delの定義及び使い方
del関数は、オブジェクトを削除するために使用します。 Pythonでは、すべてがオブジェクトであるため、del 関数を使用して、変数、リスト、リストの一部などを削除することもできます。
# delの例2
Delete a variable:
x = "hello"del xprint(x)
# delの例3
Delete the first item in a list:
x =
["apple", "banana", "cherry"]del x[0]print(x)
❮ Home ❮ Python Keywords