- 双循环构造list 及具名元组
import collections
Card = collections.namedtuple(‘Card’,[‘rank’, ‘suit’]) # 具名元组
ranks = [str(n) for n in range(2,11)] + list(‘JQKA’) # 牌数
suits = ‘spades hearts clubs diamonds’.split() # 牌色
cards = [Card(rank, suit) for suit in self.suits
for rank in self.ranks]