博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
小玩意
阅读量:5122 次
发布时间:2019-06-13

本文共 10207 字,大约阅读时间需要 34 分钟。

随机验证码import  randomb = ''for i in range(5):    t = random.randrange(0, 9)    if t==3 or t==0:        y = random.randrange(0,9)        u1 = str(y)    else:        j = random.randrange(65,91)        u1 = chr(j)    b += u1print (b)

  

文本登录验证f = open('D:\E\semantic/yess.txt','r',encoding='utf-8')def func_1(user_2,pwd_2):    for i in f:        i1 = i.strip()        i2 = i1.partition('$')        if user_2 == i2[0] and pwd_2 == i2[2]:            return True    return Falseuser_1 = input('请输入账号:')pwd_1 = input('请输入密码')f = func_1(user_1,pwd_1)if f:    print('登录成功')else:    print('失败')

  

文本登录验证升级版f = open('D:\E\semantic/yess.txt','r',encoding='utf-8')def func_1(user_3,pwd_3):    for i in f:        i1 = i.strip()        i2 = i1.partition('&')        if user_3 == i2[0] and pwd_3 == i2[2]:            return True    return Falseprint('欢迎登录美国联邦系统,登录请按1,注册请按2')name = input('')if name == '2':    isexit = False    while not isexit:        p = False        user_1 = input('请输入注册账号:')        for u in f:            u1 = u.strip()            u2 = u1.partition('&')            if user_1 == u2[0]:                p = True                break        if p:            f.seek(0)            print('账号已经存在')            continue        pwd_1 = input('请输入注册密码')        print('恭喜你注册成功,欢迎登录美国联邦系统:')        name_1 = '\n' + user_1 + '&' + pwd_1        f1 = open('D:\E\semantic/yess.txt','a',encoding='utf-8')        f1.write(name_1)        f1.flush()        f1.seek(0)        isexit = True        breakuser_1 = input('请输入登录账号:')pwd_1 = input('请输入登录密码')r = func_1(user_1,pwd_1)if r:    print('登录成功')else:    print('失败')

  

函数版:f = open('D:\E\semantic/yess.txt','r',encoding='utf-8')def func_1(user_3,pwd_3):    for i in f:        i1 = i.strip()        i2 = i1.partition('&')        if user_3 == i2[0] and pwd_3 == i2[2]:            return True    return Falsedef Verify(user_name):    user_pwd = input('请输入注册密码:')    name = '\n' + user_name + '&' + user_pwd    f = open('D:\E\semantic/yess.txt','a',encoding='utf-8')    f.write(name)    f.flush()    Sign()def register():    while True:        isexit = False        isexit_1 = False        user_2 = input('请输入注册账号:')        for u in f:            u1 = u.strip()            u2 = u1.partition('&')            if user_2 == u2[0]:                isexit = True                f.seek(0)                break            else:                isexit_1 = True        if isexit:            print('账号已经存在,请重新注册。')            continue        elif isexit_1:            f.seek(0)            Verify(user_2)            breakdef Sign():    inp_1 = input('欢迎登录美国联邦系统,登录请按1,注册请按2.\n')    if inp_1 == '1':        user_1 = input('请输入登录账号:')        pwd_1 = input('请输入登录密码')        r = func_1(user_1,pwd_1)        if r:            print('登录成功')        else:            print('失败')    elif inp_1 == '2':        register()Sign()

  

验证码版本:import  randomf = open('D:\E\semantic/yess.txt','r',encoding='utf-8')def func_1(user_3,pwd_3):    for i in f:        i1 = i.strip()        i2 = i1.partition('&')        if user_3 == i2[0] and pwd_3 == i2[2]:            return True    return Falsedef Verify(user_name):    user_pwd = input('请输入注册密码:')    name = '\n' + user_name + '&' + user_pwd    f = open('D:\E\semantic/yess.txt','a',encoding='utf-8')    f.write(name)    f.flush()    Sign()def register():    while True:        isexit = False        isexit_1 = False        user_2 = input('请输入注册账号:')        for u in f:            u1 = u.strip()            u2 = u1.partition('&')            if user_2 == u2[0]:                isexit = True                f.seek(0)                break            else:                isexit_1 = True        if isexit:            print('账号已经存在,请重新注册。')            continue        elif isexit_1:            f.seek(0)            Verify(user_2)            breakdef yzm():    b = ''    for i in range(5):        t = random.randrange(0, 9)        if t==3 or t==0:            y = random.randrange(0,9)            u1 = str(y)        else:            j = random.randrange(65,91)            u1 = chr(j)        b += u1    return bdef Sign():    inp_1 = input('欢迎登录美国联邦系统,登录请按1,注册请按2.\n')    if inp_1 == '1':        y = yzm()        user_1 = input('请输入登录账号:')        pwd_1 = input('请输入登录密码')        print(y)        while True:            yzm_1 = input('请输入验证码')            yzm_2=yzm_1.upper()            if y == yzm_2:                break            else:                print('验证码错误')        r = func_1(user_1,pwd_1)        if r and y == yzm_2:            print('登录成功')        else:            print('登录失败用户名密码错误:')    elif inp_1 == '2':        register()Sign()

  

函数升级版#验证账号def Sign_Sign(user_name):    f = open('D:\E\semantic/py.txt','r',encoding='utf-8')    f.seek(0)    for i in f:        i1 = i.strip()        i2 = i1.partition('&')        if user_name == i2[0]:            return True    return False#验证密码def pwd_pwd(user_pwd):    f = open('D:\E\semantic/py.txt','r',encoding='utf-8')    f.seek(0)    for i in f:        i1 = i.strip()        i2 = i1.partition('&')        if user_pwd == i2[2]:            return True    return False#添加新密码def modify_pwd(pwd_modify,pwd_r):    f = open('D:\E\semantic/py.txt','r',encoding='utf-8')    f.seek(0)    list_1 = []    for i in f:        i1 = i.strip()        i2 = i1.partition('&')        if pwd_modify == i2[0]:            name = pwd_modify + '&' + pwd_r + '\n'            list_1.append(name)            continue        list_1.append(i)    print(list_1)    f1 = open('D:\E\semantic/py.txt','a+',encoding='utf-8')    f1.seek(0)    f1.truncate()    for u in list_1:        f1.write(u)    f1.flush    print('yes')#主def Sign():    inp_1 = input('欢迎登录yellow网,登录请按1,注册请按2.修改密码请按3.\n')    isexit = False    #登录    if inp_1 == '1':        while not isexit:            user_1 = input('请输入登录账号:')            pwd_1 = input('请输入登录密码')            r = Sign_Sign(user_1)            print(r)            b = pwd_pwd(pwd_1)            print(b)            if r and b:                print('登录成功')                break            else:                print('用户名和密码错误,请重新输入:')    #注册    elif inp_1 == '2':        while not isexit:            user_1 = input('请输入注册账号:')            r = Sign_Sign(user_1)            if r:                print('账号已经存在')                continue            break        pwd_1 = input('请输入注册密码')        name = '\n' + user_1 + '&' + pwd_1        f = open('D:\E\semantic/py.txt','a+',encoding='utf-8')        f.write(name)        f.flush()        print('恭喜注册成功,请刷新登录')        Sign()    #修改密码    elif inp_1 == '3':        while not isexit:            user_1 = input('请输入登录账号:')            pwd_1 = input('请输入登录密码')            r = Sign_Sign(user_1)            b = pwd_pwd(pwd_1)            if r and b:                while not isexit:                    pwd_s = input('请输入新密码:')                    pwd_r = input('再次输入新密码')                    if pwd_r == pwd_s:                        modify_pwd(user_1,pwd_r)                        Sign()                        return                    else:                        print('两次密码不一致')            else:                print('用户名和密码错误,请重新输入:')Sign()

  

函数验证码升级版 无bug:import  random#验证账号def Sign_Sign(user_name):    f = open('D:\E\semantic/py.txt','r',encoding='utf-8')    f.seek(0)    for i in f:        i1 = i.strip()        i2 = i1.partition('&')        if user_name == i2[0]:            return True    return False#验证密码def pwd_pwd(user_pwd):    f = open('D:\E\semantic/py.txt','r',encoding='utf-8')    f.seek(0)    for i in f:        i1 = i.strip()        i2 = i1.partition('&')        if user_pwd == i2[2]:            return True    return False#添加新密码def modify_pwd(pwd_modify,pwd_r):    f = open('D:\E\semantic/py.txt','r',encoding='utf-8')    f.seek(0)    list_1 = []    for i in f:        i1 = i.strip()        i2 = i1.partition('&')        if pwd_modify == i2[0]:            name = pwd_modify + '&' + pwd_r + '\n'            list_1.append(name)            continue        list_1.append(i)    f1 = open('D:\E\semantic/py.txt','a+',encoding='utf-8')    f1.seek(0)    f1.truncate()    for u in list_1:        f1.write(u)    f1.flush#验证码def vcation():    while True:        vcation_str = ''        for i in range(5):            t = random.randrange(0, 9)            if t==3 or t==0:                y = random.randrange(0,9)                u1 = str(y)            else:                j = random.randrange(65,91)                u1 = chr(j)            vcation_str += u1        print (vcation_str)        vcation_1 = input('请输入验证码:')        vcation_2 = vcation_1.upper()        if vcation_2 == vcation_str:            return True        print('验证码错误请重新输入:')#主def Sign():    inp_1 = input('欢迎登录yellow网,登录请按1,注册请按2.修改密码请按3.\n')    isexit = False    #登录    if inp_1 == '1':        while not isexit:            user_1 = input('请输入登录账号:')            pwd_1 = input('请输入登录密码')            vcation()            r = Sign_Sign(user_1)            b = pwd_pwd(pwd_1)            if r and b:                print('登录成功')                break            else:                print('用户名和密码错误,请重新输入:')    #注册    elif inp_1 == '2':        while not isexit:            user_1 = input('请输入注册账号:')            vcation()            r = Sign_Sign(user_1)            if r:                print('账号已经存在')                continue            break        pwd_1 = input('请输入注册密码')        name = '\n' + user_1 + '&' + pwd_1        f = open('D:\E\semantic/py.txt','a+',encoding='utf-8')        f.write(name)        f.flush()        print('恭喜注册成功,请刷新登录')        Sign()    #修改密码    elif inp_1 == '3':        while not isexit:            user_1 = input('请输入登录账号:')            pwd_1 = input('请输入登录密码')            vcation()            r = Sign_Sign(user_1)            b = pwd_pwd(pwd_1)            if r and b:                while not isexit:                    pwd_s = input('请输入新密码:')                    pwd_r = input('再次输入新密码')                    vcation()                    print('恭喜您已经成功修改密码')                    if pwd_r == pwd_s:                        modify_pwd(user_1,pwd_r)                        Sign()                        return                    else:                        print('两次密码不一致')            else:                print('用户名和密码错误,请重新输入:')Sign()

  

转载于:https://www.cnblogs.com/cloniu/p/6201631.html

你可能感兴趣的文章
Linux 普通用户拿到root权限及使用szrz命令上传下载文件
查看>>
联合体union
查看>>
人物角色群体攻击判定(一)
查看>>
JavaWeb学习过程 之c3p0的使用
查看>>
MySql Delimiter
查看>>
一步步学习微软InfoPath2010和SP2010--第九章节--使用SharePoint用户配置文件Web service(2)--在事件注册表单上创建表单加载规则...
查看>>
使用客户端对象模型读取SharePoint列表数据
查看>>
NYOJ 289 苹果(01背包)
查看>>
【啃不完的算法导论】- 动态规划 - 最长公共子序列(概念篇)
查看>>
Day39:threading模块、ThreadLocal
查看>>
[Leveldb源码剖析疑问]-block_builder.cc之Add函数
查看>>
POJ 1328 Radar Installation 贪心
查看>>
约法三章
查看>>
canvas合成图片 圣诞节新技能戴帽
查看>>
JavaScript快速入门(四)——JavaScript函数
查看>>
css调用外部字体
查看>>
The Last Practice
查看>>
c#序列化和反序列化
查看>>
使用VS Code开发.Net Core 2.0 MVC Web应用程序教程之一
查看>>
互评Beta版本(Hello World!——SkyHunter)
查看>>