[python]代码库
import random
print("=-==-==-==-==-==《密码猜猜猜》==-==-==-==-==-=")
letterList = ["A","B","C","D","E",
"F","G","H","I","J",
"K","L","M","N","O",
"P","Q","R","S","T",
"U","V","W","X","Y",
"Z","1","2","3","4",
"5","6","7","8","9",
"0"]
passwordList = []
while True:
inanx = random.randint(0,len(letterList)-1)
letter = letterList[inanx]
passwordList.append(letter)
letterList.pop(inanx)
if len(passwordList) == 6:
break
print("正确密码是由六位不重复的大写字母和数字组成,猜猜看纳(可以帮助)")
while True:
posCorrect = 0
letterCorrect = 0
user = input("请输入:")
if user == "帮助":
a = random.randint(0,3)
b = passwordList[a]
print("正确密码中存在字母"+b)
continue
if user == "Sans&Ness":#暗号
print("欢迎回来,一条咸鱼")
print("本次密码是" + str(passwordList))
break
userList = list(user)
if len(userList) !=6:
print("别乱输!")
continue
if userList == passwordList:
print("猜对了")
break
else:
if userList[0] == passwordList[0]:
posCorrect = posCorrect + 1
if userList[1] == passwordList[1]:
posCorrect = posCorrect + 1
if userList[2] == passwordList[2]:
posCorrect = posCorrect + 1
if userList[3] == passwordList[3]:
posCorrect = posCorrect + 1
if userList[4] == passwordList[4]:
posCorrect = posCorrect + 1
if userList[5] == passwordList[5]:
posCorrect = posCorrect + 1
print("位置对:" + str(posCorrect))
if userList[0] in passwordList:
letterCorrect = letterCorrect + 1
if userList[1] in passwordList:
letterCorrect = letterCorrect + 1
if userList[2] in passwordList:
letterCorrect = letterCorrect + 1
if userList[3] in passwordList:
letterCorrect = letterCorrect + 1
if userList[4] in passwordList:
letterCorrect = letterCorrect + 1
if userList[5] in passwordList:
letterCorrect = letterCorrect + 1
print("密码对:" + str(letterCorrect))