首页 > 编程语言 > 详细

python20181213

时间:2018-12-13 23:00:40      阅读:147      评论:0      收藏:0      [点我收藏+]

实现发牌器(排中不包含大小鬼),共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

原文:https://www.cnblogs.com/zhanggd/p/10117004.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!