我只是在学习python(具有VBA背景)。
为什么这本字典没有加载?我试图拿出一副完整的纸牌。
这是我的代码:
class Deck:
def load_deck(self):
suite = ('Spades', 'Hearts', 'Diamonds', 'Clubs')
rank = (2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack", "Queen", "King", "Ace")
full_deck={}
for s in suite:
for r in rank:
full_deck.setdefault(s,r)
return full_deck
raw_deck = Deck()
raw_deck1 = raw_deck.load_deck()
print raw_deck1
这是我的输出:
{'Hearts': 2, 'Clubs': 2, 'Spades': 2, 'Diamonds': 2}