day16-斗地主作业

斗地主

import random


def Landlords():
   poker = ['大王', '小王', '♠2', '♥2', '♣2', '♦2', '♠A', '♥A', '♣A', '♦A',
            '♠K', '♥K', '♣K', '♦K', '♠Q', '♥Q', '♣Q', '♦Q', '♠J', '♥J', '♣J', '♦J',
            '♠10', '♥10', '♣10', '♦10', '♠9', '♥9', '♣9', '♦9', '♠8', '♥8', '♣8', '♦8',
            '♠7', '♥7', '♣7', '♦7', '♠6', '♥6', '♣6', '♦6', '♠5', '♥5', '♣5', '♦5',
            '♠4', '♥4', '♣4', '♦4', '♠3', '♥3', '♣3', '♦3']
   new_poker = poker.copy()
   player = random.sample(poker, 54)
   player1 = player[0:51:3]
   player2 = player[1:51:3]
   player3 = player[2:51:3]
   player4 = player[51:54]
   new_player1 = []
   new_player2 = []
   new_player3 = []
   new_player4 = []
   for i in new_poker:
       if i in player1:
           new_player1.append(i)
       elif i in player2:
           new_player2.append(i)
       elif i in player3:
           new_player3.append(i)
       else:
           new_player4.append(i)
   print('玩家1:', new_player1, '\n'
         '玩家2:', new_player2, '\n'
         '玩家3:', new_player3, '\n'
         '底牌:', new_player4)


Landlords()

上一篇:设计模式十:观察者模式


下一篇:期刊论文在线投稿审稿系统②(投稿人功能页-'我要投稿'功能的实现)