我是Python的初学者。我只知道C++ +C,所以…
我的问题是append
到我的数组中的某个对象是Card
,有两个参数,卡片有颜色和值
部分代码不起作用
class Game:
table = []
....
def play(self, *players):
for singlePlayer in players:
self.table.append(singlePlayer.throwCard())
函数throwCard()
在Player
def throwCard(self):
cardToThrow = self.setOfCards[0]
del self.setOfCards[0]
return cardToThrow
“主要”
player1 = Player()
player2 = Player()
game = Game()
game.play([player1, player2])
你有什么建议吗?你知道吗
AttributeError: 'list' object has no attribute 'throwCard'
这个
play
方法要求参数是平坦的,而不是显式地给出一个列表。我是说,你应该。。。你知道吗检查this SO post。你知道吗
尝试更改:
收件人:
我应该这么做。你知道吗
相关问题 更多 >
编程相关推荐