#/usr/bin/env python3
#coding:utf-8
import os
import sys
import getpass
import json
storage_user_file = "./username.py"
correct_user = "kk"
correct_pass = "kk"
for i in range(3):
existing_users_dict = json.load(open(storage_user_file,‘r‘))
get_user = input("please your username ")
get_pass = input("please your password ")
if correct_user == get_user and correct_pass == get_pass:
print ("Welcome to login..")
break
else:
if get_user in existing_users_dict:
if existing_users_dict[get_user] >= 3:
print ("You are locked")
break
else:
existing_users_dict[get_user]+=1
json.dump(existing_users_dict,open(storage_user_file,"w"))
print ("The user name or password you entered is incorrect.")
else:
existing_users_dict[get_user] = 1
json.dump(existing_users_dict,open(storage_user_file,"w"))
print ("The user name or password you entered is incorrect.")