#coding:utf-8 import random import time
#扑克牌54张 #间隔2秒发牌 #poker = [x for x in range(1, 55)] poker = [x for x in range(1, 55)] player = {} pokers = {} # 每个花色的组合 #玩家4人 for p in range(1, 5): player[p] = [] #4个花色 A=['♥','♠','♦','♣'] B = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] i = 1 for t in A: # 每个人的数量 print(4*13)= 522 for n in B: pokers[i] = [t, n] i += 1 pokers[53] = ['j', 'ocker'] pokers[54] = ['J', 'ocker']
for i in range(1, 55): m = random.choice(poker) poker.remove(m) # 下标为m的移除掉 即随机移除一个重复的 player[i % 4 + 1].append(m) # 依次给玩家1234加牌 数字 print('---开始发牌---') for j in player: print('玩家', j) for x in player[j]: print(pokers[x][0] + str(pokers[x][1]), end=',') print() # [x][0] #取花色 [x][1] #取数字 time.sleep(2) print('---发牌结束---')