pythonのお勉強 classの作成
class keywordで宣言。
__init__は所謂コンストラクタの定義。selfはthisのように自身を指す。self引数は省略不可。
class test: def __init__(self, arg1, arg2): self.name = arg1 self.status = arg2 t = test( "TEST1", 1 ) print t.name
class keywordで宣言。
__init__は所謂コンストラクタの定義。selfはthisのように自身を指す。self引数は省略不可。
class test: def __init__(self, arg1, arg2): self.name = arg1 self.status = arg2 t = test( "TEST1", 1 ) print t.name