简体   繁体   English

我如何制作用户配置文件,以便我输入姓名、邮件等,然后保存,以便我可以登录

[英]How do i make a user profile so that i will input the name, mail etc. and then it saves, so i can login

class User:


    def __init__(self, username, email, date_of_birth, password):
        self.username = username
        self.email = email
        self.date_of_birth = date_of_birth
        self.password = password

    @staticmethod
    def login_or_register():
        userinput = input("login or register")


    def register(self):
        pass

    def login(self, login_reg):
        self.login_reg = login_reg

How do i make a user profile so that i will input the name, mail etc. and then it saves so i can login我如何制作用户配置文件,以便我输入姓名、邮件等,然后保存以便我可以登录

heres a really simple way to do it:这是一个非常简单的方法:

import hashlib

db = {}

hash = lambda x: hashlib.md5(x.encode()).hexdigest()

def register(user, password, mail):
    db[user] = {"password": hash(password), "mail": mail}

def login(user, password):
    if db[user]["password"] == hash(password):
        print("success!")
    else:
        print("fail")

register("ironkey", "password123", "example@example.com")

login("ironkey", "password")
login("ironkey", "password123")

# get credentials for the user ironkey
print(db["ironkey"])
fail
success!
{'password': '482c811da5d5b4bc6d497ffa98491e38', 'mail': 'example@example.com'}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Homebrew,PIP,easy_install等如何工作以便我可以清理 - How do Homebrew, PIP, easy_install etc. work so that I can clean up 如何制作程序,以便用户可以指定文件名? - How do I make my program so that the user can specify a file name? 我如何使它可以循环? - How do I make it so it can loop? Discord Python:如何保护变量中的用户名/ID,以便我可以使用它来调整他们的角色 - Discord Python: How do i safe a User Name/ID in a variable so i can use it to adjust their roles 如果用户在我的 if 语句后回答“否”,我如何才能让代码再次询问您的姓名? - How do I make it so that the code will ask you your name again if the user answers no after my if statement? 为什么 Python 会打印特殊字符 @#$ 等,当我特别说不要这样做时? - Why Python prints special characters @#$ etc. when I specifically said not to do so? 我该如何做,以便用户只有两次尝试输入有效的输入? - How can I make it so the user only has 2 tries to enter valid input? 我如何继续循环我的程序,以便用户可以输入尽可能多的内容? - How do i keep looping the same my program so the user can input as much as they want? 如果用户说“不”,我该如何做到这一点,以便我的代码可以返回一行 - How do I make it so my code can return to a line if the User says No 事件可以执行命令吗? 如果是这样,我怎样才能让我的人这样做? - Can an event execute a command? If so, how can I make my one do so?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM