用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - python代码库

猜密码

2020-10-18 作者: 一条咸鱼举报

[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))


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...