Python 简单模拟斗地主发牌


#coding = utf-8

import random

def Creat_Card():
    card_type = ['♥','♠','♦','♣']
    card_values= ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
    n=1
    cards = ['大J','小J']
    for i in card_type:
        for j in card_values:
            cards.append((i+j))
            n += 1
    print('牌库生成中.............')
    print(cards.__len__())
    return cards


def WashAndPush_Card(cards):
    print('洗牌中.............')
    wash_card = random.shuffle(cards)   #shuffle可以直接将排序打乱
    print('发牌中')

    print('底 牌 : %s' %cards[0:3])

    player1 = cards[3:20]
    player2 = cards[20:37]
    player3 = cards[37:54]

    print ('player1 : '+ str(player1))
    print ('player2 : '+ str(player2))
    print ('player3 : '+ str(player3))



if __name__ == '__main__':
    WashAndPush_Card(Creat_Card())

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM