python模拟发牌小游戏
作者:互联网
import random A=['♥','♠','♦','♣'] //花色 B=['A','2','3','4','5','6','7','8','9','10','J','Q','K'] //牌面,没有大小王 poker1=[] poker2=[] poker3=[] poker4=[] pokers=[] for i in A: for j in B: pokers.append(i+j) //造一副牌,放到pokers列表中
//轮流抓牌 n = 1 for i in range(52): p = random.choice(pokers) if n % 4 == 1: poker1.append(p) if n % 4 == 2: poker2.append(p) if n % 4 == 3: poker3.append(p) if n % 4 == 0: poker4.append(p) n += 1 pokers.remove(p)
poker1.sort() poker2.sort() poker3.sort() poker4.sort()print(poker1) print(poker2) print(poker3) print(poker4)
标签:pokers,poker3,poker1,poker2,python,poker4,小游戏,发牌,append 来源: https://www.cnblogs.com/ooops/p/14824121.html