码迷,mamicode.com
首页 > 编程语言 > 详细

python20181213

时间:2018-12-13 23:30:02      阅读:312      评论:0      收藏:0      [点我收藏+]

标签: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()    

 

python20181213

标签:for   color   rand   import   def   obj   __init__   card   shu   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!