python20181213
Posted zhanggd
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python20181213相关的知识,希望对你有一定的参考价值。
实现发牌器(排中不包含大小鬼),共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()
以上是关于python20181213的主要内容,如果未能解决你的问题,请参考以下文章