标签:for color rand import def obj __init__ card shu
实现发牌器(排中不包含大小鬼),共4个玩家,每人13张牌
from random import* class Cards(object): def __init__(self,number,color): self.number = number self.color = color def Fultter(self): s = self.number col = self.color m = [] for i in col: for j in s: y ="{}{}".format(i,j) m.append(y) shuffle(m) n = [m[i] for i in range(0,13)] print("第一个人的牌{}".format(n)) m[:13]=[] x = [m[i] for i in range(0,13)] print("第二个人的牌{}".format(x)) m[:13]=[] z = [m[i] for i in range(0,13)] print("第三个人的牌{}".format(z)) m[:13]=[] i = [m[i] for i in range(0,13)] print("第四个人的牌{}".format(i)) s1 = Cards([‘A‘, 2, 3, 4, 5, 6, 7, 8, 9, 10, ‘J‘, ‘Q‘, ‘K‘],["黑桃","红桃","梅花","方片"]) s1.Fultter()
标签:for color rand import def obj __init__ card shu
原文地址:https://www.cnblogs.com/zhanggd/p/10117004.html