2018-09-05から1日間の記事一覧
「クラスオブジェクトを文字列で返すメソッド」です class Hoge(): title = "this is Hoge." def __str__(self): return self.title # クラスオブジェクトを表示すると print(Hoge()) # this is Hoge. # インスタンスでもOK hoge = Hoge() print(hoge) # thi…
「クラスオブジェクトを文字列で返すメソッド」です class Hoge(): title = "this is Hoge." def __str__(self): return self.title # クラスオブジェクトを表示すると print(Hoge()) # this is Hoge. # インスタンスでもOK hoge = Hoge() print(hoge) # thi…