Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

json and python login system

import json


print("LoginSystem @mvtthis")
myRL = input("Login or Register?")


if myRL == "Register":
    User = input("Username:") 
    PW = input("Password:")
    PW1 = input("Confirm Password:")

    if(PW == PW1):
        print("Registration successfully.")
        
        with open('LoginSystemData.json', 'a') as f:      
                f.write("
" + User + "," + PW)
                
    else:
        print("Registration failed! Please confirm your Password correctly.") 

if myRL == "Login":
    User = input("Username:") 
    PW = input("Password:")
    success = False
    with open('LoginSystemData.json', 'r') as f: 
        for i in f:
            a,b = i.split(",")
            b = b.strip()
            a = a.strip()
            if(a==User and b==PW):
                print("Login successful")
            else:
                print("Login failed. Wrong Username or Password.")     
            f.close() 
            break
Comment

json and python login system

...

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()
Comment

PREVIOUS NEXT
Code Example
Python :: python dictionary get keys and values 
Python :: question command python 
Python :: python documentation 
Python :: turtle keep window open 
Python :: dict get list of values 
Python :: python console game 
Python :: bringing last column to first: Pandas 
Python :: Video to text convertor in python 
Python :: how to run shell command in python 
Python :: How To Get Redirection URL In Python 
Python :: combine df columns python 
Python :: rotating circular queue in python 
Python :: concatenate two tensors pytorch 
Python :: pandas concat 
Python :: python compiler to exe 
Python :: mean squared error 
Python :: install chrome driver python 
Python :: django insert template in another template 
Python :: markers seaborn 
Python :: python async await run thread 
Python :: plotly go axis labels 
Python :: ModuleNotFoundError: No module named 
Python :: python callable type hint 
Python :: settings.debug django 
Python :: python try and except 
Python :: make widget span window width tkinter 
Python :: how to copy file from local to sftp using python 
Python :: split stringg to columns python 
Python :: beautifulsoup find text contains 
Python :: information of environment variables in python 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =