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)
每次运行此程序时,都会收到一条错误消息,提示“对象‘手’没有属性‘卡片’。我该如何纠正?
您在初始化类时使用了错误的关键字它应该是init而不是int。
def __init__(self):
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句