2020-07-01 13:08

# 各位大佬帮忙看看哪里错了

``````import random
xitong=random.randint(0,2)
if xitong==0:
xitong="剪刀"
else:
if xitong==1:
xitong="石头"
else:
xitong="布"

people=input("请你输入石头/剪刀/布：")

if xitong==people:
print("系统：",xitong)
print("平局")
elif xitong==0:
print("系统：",xitong)
if people=="石头":
print("你赢了")
else:
print("你输了")
elif xitong == 1:
print("系统：",xitong)
if people == "剪刀":
print("你输了")
else:
print("你赢了")
else:
xitong == 2
print("系统：",xitong)
if people == "剪刀":
print("你赢了")
else:
print("你输了")
``````
• 点赞
• 写回答
• 关注问题
• 收藏
• 复制链接分享
• 邀请回答

#### 1条回答

• い未亡程序猿！ 9月前

代码逻辑问题不大,
但得从, 输入是否正确,开始
然后, 判断平局
然后,判断你赢的可能
最后是你输得可能

``````import random
xitong=random.randint(0,2)
if xitong==0:
xitong="剪刀"
else:
if xitong==1:
xitong="石头"
else:
xitong="布"
while True:
people=input("请你输入石头/剪刀/布：")
if people != '剪刀' or people != '石头' or people != '布':
print('你的输入有误, 请重新开始!')
people = input ( "请你输入石头/剪刀/布：" )
if xitong==people:
print("系统：",xitong)
print("平局")
elif (xitong=="石头" and people=="布") or (xitong=="布" and people=="剪刀") or (xitong=="剪刀" and people=="石头"):
print("系统：",xitong)
print("你赢了")

else:
print ( "系统：", xitong )
print("你输了")

``````
点赞 评论 复制链接分享