くだすれPython(超初心者用) その26at TECH
くだすれPython(超初心者用) その26 - 暇つぶし2ch99:デフォルトの名無しさん
15/06/04 22:10:08.62 6dpaJYI0.net
>>> class Dice1:
... def __init__(self):
... face_num = 6
... print('初期化OK')
... def shoot(self):
... random.randint(1,self.face_num)
...
>>> b = Dice1()
初期化OK
>>> b.shoot()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in shoot
AttributeError: Dice1 instance has no attribute 'face_num'
なんでエラーになってしまうのでしょうか?


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch