0
私はこの問題がよく分かっていることを知っていますが、私は自分のコードを動作させることができません。私は2つのクラス、MainとPlayerLogicを持っています。ループ内に複数のPlayerLogicオブジェクトを作成したいのですが、このエラーが発生します。 "TypeError: 'モジュール'オブジェクトは呼び出し可能ではありません。ループでオブジェクトを作成するPython
EDIT:クラスは全く同じ名前の異なるファイルにありますクラス
class Main:
import PlayerLogic
numPlayers = int(input("How many player would you like? [excluding you]"))
players = []
for i in range(numPlayers):
players.append(PlayerLogic(i))
class PlayerLogic:
import random
def __init__(self,name):
self.name = str(name)
は、独自のファイルにPlayerLogicですか? 'players.append(PlayerLogic.PlayerLogic(i))'のように呼び出す必要があるかもしれません。 –
あなたは 'PlayerLogic'をインポートしますか? –
'Import PlayerLogic'は' PlayerLogic.py'をインポートしています。クラスをインポートするには、 'PlayerLogic import PlayerLogic'から試してください。 – asongtoruin