小编Ham*_*mcu的帖子

如何在python中将字符串值转换为int值

我想在python中制作一个二十一点游戏.就像一个7s的值是7但是,一个jacks值是10所以:

cards = ['ace','king','queen'....'3','2'

firstCard = random.choice(cards)

secondCard = random.choice(cards); remove.cards(firstCard)

print(int(firstCard) + int(secondCard))
Run Code Online (Sandbox Code Playgroud)

适用于数字

我怎么能为国王或王牌做到这一点......

python python-3.x

1
推荐指数
1
解决办法
327
查看次数

标签 统计

python ×1

python-3.x ×1