Python 登录注册小练习
本文最后更新于289天前,其中的信息可能已经过时,如有错误请在评论区悄悄告诉我~~~

注意

这些都是我初学随便写的,代码问题多多,还请多多理解!

使用下面的代码,要在同级目录下,添加此初始文件点击下载

有两个版本,控制台版本的写的很乱,建议看界面版本,不过都仅供参考!!!

控制台

代码

import re
import os
import copy


# 清空控制台输出
def clear_fun():
    print()
    os.system('cls')
    return


# 验证
num = re.compile(r'[0-9]')
Special_cha = re.compile(r'[^0-9a-zA-Z]')
phone_num = re.compile(r'(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}')


# 只能是大小写字母或数字,且不能以数字开头,长度为5-12位 ^(?!\d+$)[\da-zA-Z]+$
def username_fun(username_f):
    if num.match(username_f) is None and Special_cha.search(username_f) is None and 5 <= len(username_f) <= 12:
        return True
    else:
        return False


# 第一次密码必须目只能由字母大小写和数字组成,长度为6-15位
def passwd_fun(passwd_f):
    if Special_cha.search(passwd_f) is None and 6 <= len(passwd_f) <= 15:
        return True
    else:
        return False


# 第二次密码必须和第一次相同
def password_fun(password_f, passwd_f):
    if password_f == passwd_f:
        return True
    else:
        return False


# 手机号验证
def phone_number_fun(phone_number_f):
    if phone_num.search(phone_number_f) is not None:
        return True
    else:
        return False


# 存储模块txt
# 插入
def interposition_fun(info):
    with open("data.txt", "a", encoding="utf-8") as f:
        f.write(str(info) + "\n")
    return


# 读取匹配
def read_fun(info):
    with open("data.txt", "r", encoding="utf-8") as f:
        line = f.readlines()
    for i in range(len(line)):
        dictionary = line[i].strip()
        dictionary = eval(dictionary)
        if dictionary["username"] == info["username"]:
            argument = 0
            return argument, dictionary
        elif dictionary["phone_number"] == info["phone_number"]:
            argument = 1
            return argument, dictionary
        elif i >= len(line) - 1:
            argument = 2
            return argument, dictionary


# 更改
def change_fun(info, new_info, arg):
    with open("data.txt", "r", encoding="utf-8") as f:
        line = f.readlines()
        if arg == 0:
            line_1 = str(info) + "\n"
            line_2 = str(new_info) + "\n"
            line[line.index(line_1)] = line_2
        elif arg == 1:
            line_1 = str(info) + "\n"
            line.remove(line_1)
    with open("data.txt", "w", encoding="utf-8") as f:
        f.writelines(line)


# 注册程序
def register_fun():
    print("用户名格式为:只能字母数字组合,且不能以数字开头,长度为5-12位")
    username = input("请输入你的用户名:")
    if username == '退出':
        return 404
    while not username_fun(username):
        clear_fun()
        print("用户名格式有误,请重新输入!!!")
        print("用户名格式为:只能字母数字组合,且不能以数字开头,长度为5-12位")
        username = input("请输入你的用户名:")
        if username == '退出':
            return 404
    clear_fun()
    print("密码格式为:字母数字组合,且长度为6-15位")
    passwd = input("请输入你的密码:")
    if passwd == '退出':
        return 404
    while not passwd_fun(passwd):
        clear_fun()
        print("密码格式有误,请重新输入!!!")
        print("密码格式为:字母数字组合,且长度为6-15位")
        passwd = input("请输入你的密码:")
        if passwd == '退出':
            return 404
    clear_fun()
    password = input("请再次输入你的密码:")
    if password == '退出':
        return 404
    while not password_fun(password, passwd):
        clear_fun()
        print("两次密码输入不一致,请重新输入!!!")
        password = input("请再次输入你的密码:")
        if password == '退出':
            return 404
    clear_fun()
    phone_number = input("请输入你的手机号:")
    if phone_number == '退出':
        return 404
    while not phone_number_fun(phone_number):
        clear_fun()
        print("手机号格式有误,请输入正确的手机号!!!")
        phone_number = input("请输入你的手机号:")
        if phone_number == '退出':
            return 404
    dict_register = {
        "username": username,
        "passwd": passwd,
        "phone_number": phone_number
    }
    clear_fun()
    arg = read_fun(dict_register)
    if arg[0] == 0:
        print("用户名已存在,注册失败")
    elif arg[0] == 1:
        print("电话号码已存在,注册失败")
    elif arg[0] == 2:
        interposition_fun(dict_register)
        print("注册成功")
    return arg[0]


# 登录程序
def login_fun():
    username = input("请输入你的用户名:")
    if username == "退出":
        res = 404
        return res, 0
    else:
        dict_login = {'username': username, 'phone_number': '?'}
        arg = read_fun(dict_login)
        dictionary = arg[1]
        res = 4
        if arg[0] == 0:
            i = 0
            while True:
                passwd = input("请输入密码:")
                if dictionary['passwd'] == passwd:
                    print("登录成功")
                    res = 0
                    break
                elif passwd == "退出":
                    res = 404
                    return res, arg[1]
                else:
                    if i < 2:
                        i = i + 1
                        print("密码错误,还有%s次机会" % (3 - i))
                        continue
                    else:
                        print("登录失败")
                        res = 1
                        break
        else:
            clear_fun()
            print("用户不存在")
            res = 2
        return res, arg[1]


# 登陆成功后选项
def login_suc(info):
    data = info.copy()
    while True:
        print("欢迎%s使用本系统" % info['username'])
        print("请输入编号选择:\n0.退出登录\n1.更改密码\n2.注销账号")
        select_l = input("请输入编号: ")
        if select_l == "0":
            clear_fun()
            print("退出账号成功!!!")
            break
        elif select_l == "1":
            clear_fun()
            print("欢迎%s使用本系统" % info['username'])
            print("密码格式为:字母数字组合,且长度为6-15位")
            new_passwd = input("请输入你的新密码:")
            if new_passwd == '退出':
                return 404
            while not passwd_fun(new_passwd):
                clear_fun()
                print("密码格式有误,请重新输入!!!")
                print("密码格式为:字母数字组合,且长度为6-15位")
                new_passwd = input("请输入你的新密码:")
            clear_fun()
            new_password = input("请再次输入你的密码:")
            if new_password == '退出':
                return 404
            while not password_fun(new_password, new_passwd):
                clear_fun()
                print("两次密码输入不一致,请重新输入!!!")
                new_password = input("请再次输入你的新密码:")
            new_data = data.copy()
            new_data['passwd'] = new_password
            change_fun(data, new_data, 0)
            data = new_data.copy()
            print("更改密码成功!!!")
        elif select_l == "2":
            clear_fun()
            print("欢迎%s使用本系统" % info['username'])
            print("请输入编号选择:\n0.确认永久注销账号\n1.取消永久注销账号")
            select_ll = input("请输入编号: ")
            if select_ll == "0":
                change_fun(info, 0, 1)
                print("永久注销账号成功!!!")
                clear_fun()
                break
            elif select_ll == "1":
                print("取消永久注销账号成功!!!")
                clear_fun()
            elif select_ll != [0, 1]:
                clear_fun()
                print("请输入正确的编号!!!")
        elif select_l != [0, 1, 2]:
            clear_fun()
            print("请输入正确的编号!!!")


# 忘记密码程序
def forgot_password():
    clear_fun()
    print('此功能待开发!!!!!')


# 主程序
if __name__ == '__main__':
    while True:
        print("在输入的地方输入‘退出’即可退出输入")
        print("请输入编号选择:\n0.退出程序\n1.注册\n2.登录\n3.忘记密码")
        select = input("请输入编号: ")
        if select == "0":
            break
        else:
            while True:
                if select == "1":
                    while True:
                        respond_r = register_fun()
                        if respond_r == 404:
                            break
                        elif respond_r == 2:
                            break
                        else:
                            print("请输入编号选择:\n0.退出注册\n1.重新注册\n2.切换登录\n3.忘记密码")
                            select_1 = input("请输入编号: ")
                            if select_1 == "0":
                                clear_fun()
                                break
                            elif select_1 == "1":
                                clear_fun()
                                continue
                            elif select_1 == "2":
                                select = "2"
                                clear_fun()
                                break
                            elif select_1 == "3":
                                select = "3"
                                clear_fun()
                                break
                            elif select_1 != [0, 1, 2, 3]:
                                clear_fun()
                                print("输入的编号不存在,请重新输入!!!")
                                continue
                    if select == "1":
                        break
                    else:
                        continue
                elif select == "2":
                    clear_fun()
                    while True:
                        respond_l = login_fun()
                        if respond_l[0] == 404:
                            print("退出成功!!!")
                            clear_fun()
                            break
                        elif respond_l[0] == 0:
                            login_suc(respond_l[1])
                            break
                        elif respond_l[0] == 1:
                            print("请输入编号选择:\n0.退出登录\n1.重新登录\n2.切换注册\n3.忘记密码")
                            select_2 = input("请输入编号: ")
                            if select_2 == "0":
                                clear_fun()
                                break
                            elif select_2 == "1":
                                clear_fun()
                                continue
                            elif select_2 == "2":
                                select = "1"
                                clear_fun()
                                break
                            elif select_2 == "3":
                                select = "3"
                                clear_fun()
                                break
                            elif select_2 != [0, 1, 2, 3]:
                                print("输入的编号不存在,请重新输入!!!")
                                clear_fun()

                    if select == "2":
                        break
                    else:
                        continue
                elif select == "3":
                    while True:
                        forgot_password()
                        select = ""
                        break
                    break
                elif select != [0, 1, 2, 3]:
                    clear_fun()
                    print("输入的编号不存在,请重新输入!!!")
                    break

界面

代码

import tkinter as tk
from tkinter import messagebox
import re
import copy
# 验证正则
num = re.compile(r'[0-9]')
Special_cha = re.compile(r'[^0-9a-zA-Z]')
phone_num = re.compile(r'(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}')


# 用户名验证函数
def username_fun(username_f):
    if num.match(username_f) is None and Special_cha.search(username_f) is None and 5 <= len(username_f) <= 12:
        return False
    else:
        return True


# 密码验证函数
def passwd_fun(passwd_f):
    if Special_cha.search(passwd_f) is None and 6 <= len(passwd_f) <= 15:
        return False
    else:
        return True


# 第二次密码验证函数
def password_fun(password_f, passwd_f):
    if password_f == passwd_f:
        return False
    else:
        return True


# 手机号验证函数
def phone_number_fun(phone_number_f):
    if phone_num.search(phone_number_f) is not None:
        return False
    else:
        return True


# 存储模块txt
# 插入函数
def interposition_fun(info):
    with open("data.txt", "a+", encoding="utf-8") as f:
        f.write(str(info) + "\n")
    return None


# 读取匹配函数
def read_fun(info):
    with open("data.txt", "r", encoding="utf-8") as f:
        line = f.readlines()
    for i in range(len(line)):
        dictionary = line[i].strip()
        dictionary = eval(dictionary)
        if dictionary["username"] == info["username"]:
            argument = 0
            return argument, dictionary
        elif dictionary["phone_number"] == info["phone_number"]:
            argument = 1
            return argument, dictionary
        elif i >= len(line) - 1:
            argument = 2
            return argument, dictionary


# 更改函数
def change_fun(info, new_info, arg):
    with open("data.txt", "r", encoding="utf-8") as f:
        line = f.readlines()
        if arg == 0:
            line_1 = str(info) + "\n"
            line_2 = str(new_info) + "\n"
            line[line.index(line_1)] = line_2
        elif arg == 1:
            line_1 = str(info) + "\n"
            line.remove(line_1)
    with open("data.txt", "w", encoding="utf-8") as f:
        f.writelines(line)


# 注册函数
def register_fun():
    username = register_username_b.get()
    passwd = register_pass_b.get()
    password = register_password_b.get()
    phone_number = register_phone_b.get()
    if username_fun(username):
        messagebox.showerror("注册失败", "用户名格式错误,请重试。")
        return False
    if passwd_fun(passwd):
        messagebox.showerror("注册失败", "密码格式错误,请重试。")
        return False
    if password_fun(passwd, password):
        messagebox.showerror("注册失败", "两次密码不一致,请重试。")
        return False
    if phone_number_fun(phone_number):
        messagebox.showerror("注册失败", "手机号格式错误,请重试。")
        return False
    dict_register = {"username": username, "passwd": passwd, "phone_number": phone_number}
    arg = read_fun(dict_register)
    if arg[0] == 0:
        messagebox.showerror("注册失败", "用户名已存在,请重试。")
        return False
    elif arg[0] == 1:
        sel = tk.messagebox.askyesno(title='注册失败', message='电话号码已存在,是否尝试登录?')
        if sel:
            func(3)
            reset_ui()
            return None
        else:
            return False
    elif arg[0] == 2:
        interposition_fun(dict_register)
        messagebox.showinfo("注册成功", "欢迎," + username + "!请登录。")
        func(3)
        reset_ui()
        return None


# 登录函数
def login_fun():
    username = login_username_b.get()
    passwd = login_pass_b.get()
    if username_fun(username):
        messagebox.showerror("登录失败", "用户名格式错误,请重试。")
        return False
    dict_login = {'username': username, 'phone_number': '?'}
    arg = read_fun(dict_login)
    dictionary = arg[1]
    if arg[0] == 0 and dictionary['passwd'] == passwd:
        messagebox.showinfo("登录成功", "欢迎," + username + "!")
        login_data(dictionary, 0)
        reset_ui()
        return None
    elif arg[0] == 0 and dictionary['passwd'] != passwd:
        messagebox.showerror("登录失败", "密码错误,请重试。")
        return None
    elif arg[0] == 2:
        messagebox.showerror("登录失败", "用户不存在,请重试。")
        return None


# 登录传入数据函数
def login_data(info, serial):
    global overall_situation
    if serial == 0:
        overall_situation = info
        menu_tite.set("欢迎," + info['username'] + "使用本系统~~~")
        func(4)
        return None
    elif serial == 1:
        overall_situation = {}
        func(1)
        return None


# 更改密码函数
def change_password():
    passwd = pass_button.get()
    new_passwd = pass_b.get()
    new_password = password_b.get()
    if passwd != overall_situation['passwd']:
        messagebox.showerror("更改失败", "原密码错误,请重试。")
        return False
    if passwd_fun(new_passwd):
        messagebox.showerror("更改失败", "新密码不符合要求,请重试。")
        return False
    if password_fun(new_passwd, new_password):
        messagebox.showerror("更改失败", "两次密码不一致,请重试。")
        return False
    new_data = overall_situation.copy()
    new_data['passwd'] = new_passwd
    change_fun(overall_situation, new_data, 0)
    messagebox.showinfo("更改成功", "密码更改成功,请重新登录。")
    login_data(1, 1)
    return True


# 更改用户名函数
def change_user():
    global overall_situation
    new_user = user_button.get()
    if username_fun(new_user):
        messagebox.showerror("更改失败", "用户名格式错误,请重试。")
        return False
    if new_user == overall_situation['username']:
        messagebox.showerror("更改失败", "用户名未更改。")
        return False
    new_data = {'username': new_user, 'phone_number': '?'}
    age = read_fun(new_data)
    if age[0] == 0:
        messagebox.showerror("更改失败", "用户名已存在,请重试。")
        return False
    new_data = overall_situation.copy()
    new_data['username'] = new_user
    change_fun(overall_situation, new_data, 0)
    messagebox.showinfo("更改成功", "用户名更改成功。")
    overall_situation = new_data.copy()
    menu_tite.set("欢迎," + new_user + "使用本系统~~~")
    func(4)
    return None


# 注销账号函数
def sign_out():
    global overall_situation
    sel = tk.messagebox.askyesno(title='系统提示', message='确认注销账号?')
    if sel:
        change_fun(overall_situation, 1, 1)
        overall_situation = {}
        messagebox.showinfo("系统提示", "注销成功!")
        func(1)
        return None
    return None


def reset_ui():
    register_username_b.delete(0, tk.END)
    register_pass_b.delete(0, tk.END)
    register_password_b.delete(0, tk.END)
    register_phone_b.delete(0, tk.END)
    login_username_b.delete(0, tk.END)
    login_pass_b.delete(0, tk.END)
    pass_button.delete(0, tk.END)
    pass_b.delete(0, tk.END)
    password_b.delete(0, tk.END)
    user_button.delete(0, tk.END)


# 关闭程序
def close_fun():
    sel = tk.messagebox.askyesno(title='系统提示', message='是否要退出系统?')
    if sel:
        window.quit()
        window.destroy()
    else:
        return None


# 创建主窗口
window = tk.Tk()
window.title("登录/注册小程序")
window.geometry("710x540")
window.resizable(0, 0)

# 创建Frame容器
frame_home = tk.Frame(window, width=710, height=540)
frame_register = tk.Frame(window, width=710, height=540)
frame_login = tk.Frame(window, width=710, height=540)
frame_menu = tk.Frame(window, width=710, height=540)
frame_pass = tk.Frame(window, width=710, height=540)
frame_user = tk.Frame(window, width=710, height=540)
# frame_user.pack()

# 切换
frame_home.place(width=710, height=540, x=0)
frame_register.place(width=710, height=540, x=710)
frame_login.place(width=710, height=540, x=710)
frame_menu.place(width=710, height=540, x=710)
frame_pass.place(width=710, height=540, x=710)
frame_user.place(width=710, height=540, x=710)
overall_situation = {}
menu_tite = tk.StringVar()


def func(n):
    frames = [frame_home, frame_register, frame_login, frame_menu, frame_pass, frame_user]
    frames[n-1].place(width=710, height=540, x=0)
    frames.pop(n-1)
    for i in frames:
        i.place(width=710, height=540, x=710)


# <--首页开始-->
# 首页-标题
tk.Label(frame_home, text="欢迎使用本系统~~~", font=("华文仿宋", 18)).place(x=1, y=10, width=250, height=30)
# 首页-登录按钮
button_login = tk.Button(frame_home, text="登录", font=("华文仿宋", 18), command=lambda: func(3))
button_login.place(x=20, y=100, width=670, height=100)
# 首页-注册按钮
button_register = tk.Button(frame_home, text="注册", font=("华文仿宋", 18), command=lambda: func(2))
button_register.place(x=20, y=220, width=670, height=100)
# 首页-退出程序按钮
button_quit = tk.Button(frame_home, text="退出程序", font=("华文仿宋", 18), command=close_fun)
button_quit.place(x=20, y=340, width=670, height=100)
# <--首页结束-->

# <--注册开始-->
#  注册-标题
tk.Label(frame_register, text="注册", font=("华文仿宋", 30)).place(x=0, y=50, width=710, height=35)
# 注册-返回按钮
register_button = tk.Button(frame_register, text="< 返回", font=("华文仿宋", 16), command=lambda: func(1))
register_button.place(x=30, y=20, width=80, height=40)
# 注册-用户名
tk.Label(frame_register, text="用户名:", font=("华文仿宋", 14)).place(x=50, y=150, width=100, height=30)
register_username_b = tk.Entry(frame_register, font=("华文仿宋", 14))
register_username_b.place(x=160, y=150, width=250, height=30)
tk.Label(frame_register, text="字母数字组合且不能以数字开头,长度为5-12位", font=("等线", 10)).place(x=410, y=150, width=300, height=30)
# 注册-密码
tk.Label(frame_register, text="密码:", font=("华文仿宋", 14)).place(x=59, y=200, width=100, height=30)
register_pass_b = tk.Entry(frame_register, font=("华文仿宋", 14), show="*")
register_pass_b.place(x=160, y=200, width=250, height=30)
tk.Label(frame_register, text="字母数字组合,且长度为6-15位", font=("等线", 10)).place(x=410, y=200, width=210, height=30)
tk.Label(frame_register, text="确认密码:", font=("华文仿宋", 14)).place(x=40, y=250, width=100, height=30)
register_password_b = tk.Entry(frame_register, font=("华文仿宋", 14), show="*")
register_password_b.place(x=160, y=250, width=250, height=30)
# 注册-手机号
tk.Label(frame_register, text="手机号:", font=("华文仿宋", 14)).place(x=50, y=300, width=100, height=30)
register_phone_b = tk.Entry(frame_register, font=("华文仿宋", 14))
register_phone_b.place(x=160, y=300, width=250, height=30)
# 注册-提交按钮
register_submit_b = tk.Button(frame_register, text="注册", font=("华文仿宋", 15), command=register_fun)
register_submit_b.place(x=190, y=380, width=120, height=40)
# 注册-重置按钮
register_reset_b = tk.Button(frame_register, text="重置", font=("华文仿宋", 15), command=reset_ui)
register_reset_b.place(x=320, y=380, width=120, height=40)
# <--注册结束-->

#  <--登录开始-->
# 登录-标题
tk.Label(frame_login, text="登录", font=("华文仿宋", 30)).place(x=0, y=50, width=710, height=35)
# 登录-返回按钮
register_button = tk.Button(frame_login, text="< 返回", font=("华文仿宋", 16), command=lambda: func(1))
register_button.place(x=30, y=20, width=80, height=40)
# 登录-用户名
tk.Label(frame_login, text="用户名:", font=("华文仿宋", 14)).place(x=150, y=150, width=100, height=30)
login_username_b = tk.Entry(frame_login, font=("华文仿宋", 14))
login_username_b.place(x=260, y=150, width=250, height=30)
# 登录-密码
tk.Label(frame_login, text="密码:", font=("华文仿宋", 14)).place(x=159, y=200, width=100, height=30)
login_pass_b = tk.Entry(frame_login, font=("华文仿宋", 14), show="*")
login_pass_b.place(x=260, y=200, width=250, height=30)
# 登录-提交按钮
login_submit_b = tk.Button(frame_login, text="登录", font=("华文仿宋", 15), command=login_fun)
login_submit_b.place(x=260, y=300, width=120, height=40)
# 登录-重置按钮
login_reset_b = tk.Button(frame_login, text="重置", font=("华文仿宋", 15), command=reset_ui)
login_reset_b.place(x=390, y=300, width=120, height=40)
# <--登录结束-->

# <--登录菜单-->
#  标题
menu_label = tk.Label(frame_menu, textvariable=menu_tite, text="欢迎使用本系统~~~", font=("华文仿宋", 18))
menu_label.place(x=10, y=10, height=30)
# 选项
menu_button_alter = tk.Button(frame_menu, text="更改用户名", font=("华文仿宋", 18), command=lambda: func(6))
menu_button_alter.place(x=20, y=80, width=670, height=100)
menu_button_user = tk.Button(frame_menu, text="更改密码", font=("华文仿宋", 18), command=lambda: func(5))
menu_button_user.place(x=20, y=190, width=670, height=100)
menu_button_quit = tk.Button(frame_menu, text="退出登录", font=("华文仿宋", 18), command=lambda: login_data(1, 1))
menu_button_quit.place(x=20, y=300, width=670, height=100)
menu_button_out = tk.Button(frame_menu, text="注销账号", font=("华文仿宋", 18), command=sign_out)
menu_button_out.place(x=20, y=410, width=670, height=100)
# <--登录菜单结束-->

# <--更改密码开始-->
# 标题
tk.Label(frame_pass, text="更改密码", font=("华文仿宋", 30)).place(x=0, y=50, width=710, height=35)
# 返回按钮
pass_quit = tk.Button(frame_pass, text="< 返回", font=("华文仿宋", 16), command=lambda: func(4))
pass_quit.place(x=30, y=20, width=80, height=40)
# 原密码
tk.Label(frame_pass, text="原密码:", font=("华文仿宋", 14)).place(x=50, y=150, width=100, height=30)
pass_button = tk.Entry(frame_pass, font=("华文仿宋", 14), show="*")
pass_button.place(x=160, y=150, width=250, height=30)
# 新密码
tk.Label(frame_pass, text="密码:", font=("华文仿宋", 14)).place(x=59, y=200, width=100, height=30)
pass_b = tk.Entry(frame_pass, font=("华文仿宋", 14), show="*")
pass_b.place(x=160, y=200, width=250, height=30)
tk.Label(frame_pass, text="字母数字组合,且长度为6-15位", font=("等线", 10)).place(x=410, y=200, width=210, height=30)
tk.Label(frame_pass, text="确认密码:", font=("华文仿宋", 14)).place(x=40, y=250, width=100, height=30)
password_b = tk.Entry(frame_pass, font=("华文仿宋", 14), show="*")
password_b.place(x=160, y=250, width=250, height=30)
# 提交按钮
pass_submit_b = tk.Button(frame_pass, text="更改", font=("华文仿宋", 15), command=change_password)
pass_submit_b.place(x=190, y=300, width=120, height=40)
# 重置按钮
pass_reset_b = tk.Button(frame_pass, text="重置", font=("华文仿宋", 15), command=reset_ui)
pass_reset_b.place(x=320, y=300, width=120, height=40)
# <--更改密码结束-->

# <--修改用户名开始-->
# 标题
tk.Label(frame_user, text="更改用户名", font=("华文仿宋", 30)).place(x=0, y=50, width=710, height=35)
# 返回按钮
user_quit = tk.Button(frame_user, text="< 返回", font=("华文仿宋", 16), command=lambda: func(4))
user_quit.place(x=30, y=20, width=80, height=40)
# 新用户名
tk.Label(frame_user, text="新用户名:", font=("华文仿宋", 14)).place(x=50, y=150, width=100, height=30)
user_button = tk.Entry(frame_user, font=("华文仿宋", 14))
user_button.place(x=160, y=150, width=250, height=30)
tk.Label(frame_user, text="字母数字组合且不能以数字开头,长度为5-12位", font=("等线", 10)).place(x=410, y=150, width=300, height=30)
# 提交按钮
user_submit_b = tk.Button(frame_user, text="更改", font=("华文仿宋", 15), command=change_user)
user_submit_b.place(x=190, y=300, width=120, height=40)
# 重置按钮
user_reset_b = tk.Button(frame_user, text="重置", font=("华文仿宋", 15), command=reset_ui)
user_reset_b.place(x=400, y=300, width=120, height=40)
# <--修改用户名结束-->

window.mainloop()
此文章是我在学校学习时的一些过程记录,有错误还请多多包涵,仅供参考
作者:404_502
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0协议。转载请注明文章地址及作者

评论

  1. z
    10 月前
    2023-10-12 17:48:35

    大佬,请问顶栏的归档和右侧的文件目录是怎么做的(☆ω☆)

    来自山东
    • 博主
      z
      10 月前
      2023-10-12 17:56:23

      如果是同样的主题,归档就在页面里面新建页面,在右边模板选择归档时间轴,发布就有这个页面了
      文章目录这个主题好像是默认开的,在写文章的时候要添加标题

      来自广西
      • z
        404_502
        10 月前
        2023-10-12 18:29:57

        谢谢大佬,还有一个问题。
        你的右侧 站点概览里的 20 文章,一点击会跳到归档页面,而我的无法点击。请问是怎样实现的。

        来自山东
        • 博主
          z
          10 月前
          2023-10-12 23:34:50

          不好意思,刚看到,在主题的设置里有个归档页面的配置,在那里把你的归档页面地址填上就行

          来自广西
          • z
            404_502
            10 月前
            2023-10-13 15:06:54

            谢谢博主,按照你的方法我成功解决了问题。
            请问你博客中可道云是怎样实现的,是需要两台服务器吗,或者博主可以提供一些资料和教程吗?跪求>﹏<

            来自山东
          • 博主
            z
            10 月前
            2023-10-13 15:14:33

            可以部署在一台服务器上,跟wordpress部署差不多,这得看服务器的环境,具体你去搜索(系统+可道云部署)网上很多教程的

            来自广西
          • z
            404_502
            10 月前
            2023-10-13 15:20:59

            谢谢博主

            来自山东
          • z
            404_502
            10 月前
            2023-10-15 14:02:16

            大佬大佬,请问评论区的名字后面跟着系统和浏览器是如何做到的。

            来自山东
          • 博主
            z
            10 月前
            2023-10-15 14:40:48

            在主题设置里的评论下面的评论区,里面的评论者UA显示

            来自广西

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇