猜拳游戏and用户登录
Posted gxc888
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了猜拳游戏and用户登录相关的知识,希望对你有一定的参考价值。
猜拳游戏
win=0
lost=0
ping=0
while True:
print(‘胜:%s 输:%s 平:%s‘% (win,lost,ping))
print(‘欢迎来猜拳 1.拳头 2.剪刀 3.布 4.退出‘)
import random
chooses = [‘石头‘,‘剪刀‘,‘布‘]
dn = random.choice(chooses)
ren = input(‘请出拳:‘)
if (ren == ‘1‘ and dn ==‘石头‘) or (ren == ‘2‘ and dn == ‘剪刀‘) or (ren==‘3‘ and dn ==‘布‘):
ping += 1
print(‘平局‘)
elif (ren == ‘1‘ and dn == ‘剪刀‘) or (ren == ‘2‘ and dn == ‘布‘) or (ren == ‘3‘ and dn == ‘石头‘):
win += 1
print(‘赢啦‘)
elif (ren == ‘1‘ and dn == ‘布‘) or (ren == ‘2‘ and dn == ‘石头‘) or (ren == ‘3‘ and dn == ‘剪刀‘):
lost += 1
print(‘输啦‘)
elif (ren == ‘4‘):
break
elif not ren:
continue
else:
print(‘输入错误‘)
print(‘ 33[31m= 33[0m‘ * 30)
用户登录
username = ‘root‘
password = ‘root‘
count = 0
print(‘请登录...‘)
while True:
user = input(‘username:‘)
pwd = input(‘password:‘)
if user == username and pwd == password:
print(‘欢迎登陆‘)
break
else:
count += 1
print(‘密码错误‘, count)
if count == 3:
print(‘滚‘)
break
以上是关于猜拳游戏and用户登录的主要内容,如果未能解决你的问题,请参考以下文章