功能卡游戏中的功能

时间:2018-02-09 01:18:22

标签: python function for-loop

我不熟悉功能,但不知何故让方案1工作并打印出一组5张随机卡,如下所示:A 3 J 2 8.但是我试图使用函数{{1在} poker_hand中,以获得类似的内容:

poker_game

但输出看起来像:

Player 1: # # # # #,
Player 2: # # # # #, 
etc. 

怎么能修好?

5 6 10A 5 Player 2 <function poker_hand at 0x105818400>
K 7 A 2 6 Player 3 <function poker_hand at 0x105818400>
Q 104 3 3 Player 4 <function poker_hand at 0x105818400>
8 102 K 7 Player 5 <function poker_hand at 0x105818400>
5 2 A 6 2 Player 6 <function poker_hand at 0x105818400>
Q A 5 9 6 Player 7 <function poker_hand at 0x105818400>
A A 8 3 9 Player 8 <function poker_hand at 0x105818400>
K 8 3 J K Player 9 <function poker_hand at 0x105818400>

cards = ['A ', '2 ', '3 ', '4 ', '5 ', '6 ', '7 ', '8 ', '9 ', '10', 'K 
', 'Q ', 'J ']

def poker_hand(x):
    for i in range(0, 5):
        pick = random.choice(cards)
        print(pick, end='')
    return poker_hand

poker_hand(cards)

1 个答案:

答案 0 :(得分:0)

我认为你很亲密。我做了一些小编辑:

Player 2: 3 9 K 7 2 
Player 3: 8 2 J 7 8 
Player 4: 7 10 3 3 3 
Player 5: 5 J J A 2 
Player 6: 10 6 6 J 10 
Player 7: K 8 6 Q J 
Player 8: 9 Q 3 4 K 
Player 9: 10 8 8 7 Q 

这导致:

<field-validator type="regex">
    <param name="regexExpression">[^[/^(\d)\1+$/g]]</param>
    <message>${getText("bookReq.bookId.err")}</message>
</field-validator>