📜  json和python登录系统——Python代码示例

📅  最后修改于: 2022-03-11 14:47:02.642000             🧑  作者: Mango

代码示例2
...

if myRL == "Login":
    User = input("Username:") 
    PW = input("Password:")
    with open('LoginSystemData.json', 'r') as f: 
        readable = f.read() # --> you need to readable:str your file
        lines = readable.splitlines() # --> ['name,pw','name,pw','name,pw']
        user = list(filter(lambda l:l.split(',')[0] == User and l.split(',')[1] == PW,lines))
        if user:
               print("Login successful")
        else:
               print("Login failed. Wrong Username or Password.")     
        f.close()