- 博客(2)
- 收藏
- 关注
原创 闲来无事写个python猜拳游戏
#猜拳游戏:电脑随机产生石头剪刀布,键盘输入你要出的拳,(布:0 剪刀 1 石头 2),判断哪方赢 import random count=1 game = {“0”:“布”,“1”:“剪刀”,“2”:“石头”} while count<=3: comp=random.randrange(3) you=int(input(“0:布\n1:剪刀\n2:石头\n你出拳:\n”)) if youc...
2019-09-11 19:06:55 416
原创 python中字反转符串方法
要求:在Python环境下用尽可能多的方法反转字符串,例如将s = "abcdef"反转成 “fedcba” 第一种:使用字符串切片 result = s[::-1] 第二种:使用列表的reverse方法 l = list(s) l.reverse() result = “”.join(l) 当然下面也行 l = list(s) result = “”.join(l[::-1]) 第三种:使用re...
2019-09-03 18:58:27 203
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人