1 # 需要在python3上执行 2 import random 3 # “Test” 是 account_login函数 的文件名字 4 from Test import account_login 5 # import Test 6 7 def game (capital = 1000): 8 point1 = random.randrange(1,7) 9 point2 = random.randrange(1,7) 10 point3 = random.randrange(1,7) 11 print("<<<<<<<<<< 游戏开始 >>>>>>>>>>") 12 result = point3 + point2 + point1 13 大 = range(11,19) 14 小 = range(3,11) 15 print("请选择大小,如果选择“大”请输入“大”,否则输入“小”") 16 cai = input("大 or 小: ") 17 if cai == '大' or cai == '小': 18 print("您的本金有",capital) 19 xiaZhu = input("您想下注多少钱?(请输入正整数,并且不能超过本金): ") 20 if xiaZhu.isdigit(): 21 if abs(float(xiaZhu)) > capital: 22 print("***您下的注金不能高过您的本金,您的本金还有:",str(capital)+"元,请重新下注! ") 23 game(capital = capital) 24 else: 25 print('<<<<<<<<< 买定离手,开始摇筛子了!!! >>>>>>>>>') 26 if cai == '大': 27 if result in 大: 28 print("点数是"+ str([point3, point2, point1]),"You Win!") 29 capital = capital + abs(float(xiaZhu)) 30 print('您赢得了'+ str(abs(float(xiaZhu)))+'元'+',您现在有'+ str(capital)+ '元 ') 31 else: 32 print("摇得的点数是"+ str([point3, point2, point1]),"You Lose!") 33 capital = capital - abs(abs(float(xiaZhu))) 34 print('您输了' + str(xiaZhu) + '元' + ',您现在有' + str(capital) + '元 ') 35 else: 36 cai == '小' 37 if result in 小: 38 print("点数是"+ str([point3, point2, point1]),"You Win") 39 capital = capital + abs(abs(float(xiaZhu))) 40 print('您赢得了' + str(abs(float(xiaZhu))) + '元' + ',您现在有' + str(capital) + '元 ') 41 else: 42 print("点数是"+ str([point3, point2, point1]),"You Lose!") 43 capital = capital - abs(float(xiaZhu)) 44 print('您输了' + str(abs(float(xiaZhu))) + '元' + ',您现在有' + str(capital) + '元 ') 45 if capital <=0: 46 print("*** 您的资金已经用光,GAME OVER!!! ***") 47 quit() 48 else: 49 i = 1 50 while i > 0: 51 game(capital = capital) 52 else: 53 print("***下注资金只能是正整数,请您重新下注*** ") 54 game(capital = capital) 55 else: 56 print("***选择大小时仅允许输入 “大” 或 “小”,请重新下注!*** ") 57 game(capital = capital) 58 59 if account_login(): 60 game() 61 else: 62 print("登录失败,请重新操作") 63 account_login()
1 #Test 文件代码 2 # 登录操作 3 PassWord_list = [] 4 Reset_pw = '*#*#' 5 def account_login(): 6 if PassWord_list == []: 7 PassWord = input("请设置初始登录密码:") 8 if PassWord.isalnum(): 9 PassWord_list.append(PassWord) 10 else: 11 print("密码只能是输入或字母,请重新输入") 12 account_login() 13 else: 14 num = 3 15 while num > 0: 16 password = input('请输入您的登录密码: ') 17 correct_password = password == PassWord_list[-1] 18 reset_password = password == Reset_pw 19 if correct_password: 20 print("登录成功") 21 return True 22 elif reset_password: 23 new_password = input('请输入要重置的密码: ') 24 if new_password.isalnum(): 25 PassWord_list.append(new_password) 26 else: 27 print("密码只能是输入或字母,请重新输入") 28 account_login() 29 print('密码已经重置成功,请输入重置的密码登录') 30 account_login() 31 else: 32 print("您输入的密码错误,请再次输入或输入'*#*#'重置密码") 33 num = num -1 34 print(num,'time left') 35 print("输入次数过多") 36 account_login()