其他分享
首页 > 其他分享> > day16-斗地主作业

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()

标签:poker,斗地主,player3,作业,player2,player,day16,player1,new
来源: https://blog.csdn.net/qq_44981522/article/details/122050265