The ATM-8 of Python basics

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.