我正在尝试创建登录系统程序,其中“姓名”、“电子邮件”和“密码”必须从用户处作为输入,并保存为文本文件中的字典。我被困在如何给每个命题分配一个变量上。
此外,一旦用户注册后再次出现,应该对字典文本文件进行密码检查,我不确定。请查看下面的代码并提供帮助?
#! usr/bin/python3
# Login project sample
import json
def login():
print("Welcome to login system")
New_user = input("Are you a new user? type yes or no: ")
if New_user == "yes":
a = {}
Name = input("Enter your name: ")
Email = input("Enter the email: ")
Password = input("Enter the password: ")
a["Name"] = (Name)
a["Email"] = (Email)
a["Password"] = (Password)
print(a)
with open("login.txt", "a+") as f:
f.seek(0)
data = f.read(100)
if len(data) > 0:
f.write("\n")
x = str(range(1,100))
f.write(x + "=" + json.dumps(a))
x = x + 1
else:
b={}
def login1():
Email = input("Enter the email: ")
Password = input("Enter the password: ")
b["Email"] = (Email)
b["Password"] = (Password)
with open("login.txt", "r") as r:
f.seek(0)
i = range(100)
if i.keys() in b.keys() and i.value() in b.value():
print("Login is successfull")
else:
login1()
login()