Import JSON
From core import accounts
Import datetime
‘‘‘
This module is manage, the implementation of the Administrator's portal, to add accounts, modify the quota, frozen accounts
‘‘‘
def manage (_user,_pass):
‘‘‘
This function realizes the information account management, the default user name and password are admin
:p Aram _user:
:p Aram _pass:
: return:
‘‘‘
If _user = = "Admin" and _pass = = "Admin":
Print ("Welcome to%s login Credit card management system"%_user)
Print ("1. Add an account 2. User Quota 3. Freezing accounts")
Choose = Input ("Please enter your actions >>>")
If choose = = "1":
Add_account ()
Elif Choose = = "2":
User_limit ()
Elif Choose = = "3":
Lock_account ()
Elif Choose = = "Q":
Exit ()
Else
Print ("Input error")
Def add_account ():
Acc_acount = {}
Name = input ("Please enter name >>>"). Strip ()
account = input ("Please enter accounts >>>")
_pass = input ("Please enter password >>>")
Limit = input ("Please Enter account amount >>>")
If Limit.isdigit ():
limit = Int (limit)
Else
Print ("Input error")
acc_acount["name"] = Name
acc_acount["account") = Account
acc_acount["engine"] = str (datetime.date.today () + Datetime.timedelta (days= 365*3))
Print (acc_acount["engine"])
Acc_acount["Pass"] = _pass
acc_acount["limit"] = limit
acc_acount["used"] = 0
acc_acount["Cancash"] = acc_acount["Limit"/2
acc_acount["Status" = "normal"
Accounts.dump (Acc_acount)
Print ("Credit card account%s added successfully"%account)
Def user_limit ():
account = input ("Please enter the amount to be adjusted >>>")
Acc_account = accounts.load (account)
If Acc_account:
Print (the current quota for the "%s account is:%d"% (acc_account["accounts"],acc_account["Limit"))
New_limit = input ("Please enter adjusted amount >>>>")
If New_limit.isdigit ():
New_limit = float (new_limit)
acc_account["Limit"] = New_limit
Accounts.dump (Acc_account)
Else
Print ("The account does not exist")
Def lock_account ():
account = input ("Please enter accounts to be frozen >>>")
Acc_account = accounts.load (account)
If Acc_account:
Choise = input ("Confirm if the account is frozen (y/n)")
if choise = = "Y":
acc_account["status"] = "lock"
Accounts.dump (Acc_account)
Else
Print ("The account does not exist")
if __name__ = = ' __main__ ':
user = input ("Please enter user name >>>")
_pass = input ("Please enter password >>>")
While True:
Manage (User,_pass)
The ATM-8 of Python basics