# Python CodeRecipe|classの使い方

Home Python Keywords

# classの例

Create a class named "Person":

    class Person:  name = "John"  age = 36

# classの定義及び使い方

class関数は、クラスの作成に使用します。 クラスはオブジェクトコンストラクタのようなものです。次の例を参照して、 を使用してオブジェクトを作成できます。

# classの例

Create an object named p1, using the class from the example above:

    p1 = Person()print(p1.name)

Related Pages Read more about classes and objects in our Python Classes/Objects Tutorial.

Home Python Keywords