class Hand:
def __int__(self):
self.value= 0
self.ace=False
self.Cards = []
def __str__(self):
hand_comp=""
for card in self.Cards:
card_name=card.__str__()
hand_comp+= " " + card_name
return 'The card has %s' %(hand_comp)
def card_add(self, card):
'''Add another card to the hand'''
self.Cards.append(card)
每次运行这个时,都会出现一个错误,即“Object'Hand'没有属性'Cards'。我怎样才能纠正这个问题
初始化类时使用了错误的关键字 它应该是init而不是int
相关问题 更多 >
编程相关推荐