1 1、函数从ATM_Program--
core下的main文件运行,其中的ATM功能只能有三次登录机会。登陆成功失败与否均不允许再次登陆。
2 2
、文件Bin下的atm.py是信用卡操作主程序:例如账户间转账、存钱、提现功能
3 3
、文件夹Bin下的是manager.py是信用卡的管理端:例如冻结账户、改变信用卡额度、添加账户。
4 4
、manager.py的主程序在accounts.py里。
5 5
、logger.py日志记录模块。记录账户登陆和,购物的流水。
6 6
、transaction.py与settings.py与db_handler.py与transaction.py均暂时没有内容
7 7
、db文件是用户数据存储的地方,account_sample.py能生成初始账户数据。
8 8
、accounts文件夹下面存放各个账户,一个账户一个文件
9 9
、log文件夹下面存放日志:用户访问和交易日志存放在同一个文件夹。
10 10、shooping_mall是电子商城程序。
Readme
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Author:Source
4 import os,sys
5 import getpass
6 site_core = os.path.dirname(os.path.abspath(
__file__))
7 site_atm= os.path.dirname(os.path.dirname(os.path.abspath(
__file__)))
8 sys.path.append(site_atm)
9 sys.path.append(site_core)
10 from db
import account_sample
11 from core
import auth,small_function
12 for i
in range(3
):
13 @auth.auth
14 def log_in():
15 account = input(
'Please input your account.')
16 password = input(
'Please enter your password.')
17 # if password.isdigit():
18 # password = int(password)
19 return (account,password)
20 log_in()
21 consequence = auth.return_result()
#consequence中记载的是登录账户,每次只会记录一个
22 if consequence !=
'False':
23 while True:
24 operation_choose = input(
"Please enter your next action is:\nExample:\033[32;1m'Transfer'\033[0m"
25 ",\033[32;1m'To save money'\033[0m,\033[32;1m'Cash'\033[0m")
26 if operation_choose ==
'Transfer':
#转账
27 transfer_account = input(
'Please enter the target account to be transferred:')
28 judge =
auth.auth_account(transfer_account)
29 if judge ==
True :
30 transfer_money = input(
'Please enter the transfer amount:')
31 auth.operation_money(consequence,transfer_account,transfer_money)
32 small_function.progress_bar()
33 print(
"\033[23;1m\nOperation succeed.\033[0m")
34 else:
35 pass
36 elif operation_choose ==
'To save money':
#存钱功能
37 save_money = input(
"Please enter the deposit amount:")
38 auth.save_money(consequence,save_money)
39 elif operation_choose ==
'Cash':
#取现功能
40 cash_money = input(
"Please enter the withdrawal amount:")
41 auth.cash(consequence,cash_money)
42 elif operation_choose ==
'q':
43 break
44 else:
45 print(
'\033[31;1mPlease enter the currect opeartion.\033[0m')
46 else:
47 pass
48 #print(consequence)#test
atm.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Author:Source
4 import os,sys
5 site_core = os.path.dirname(os.path.abspath(
__file__))
6 site_atm= os.path.dirname(os.path.dirname(os.path.abspath(
__file__)))
7 sys.path.append(site_atm)
8 sys.path.append(site_core)
9 from db
import account_sample
10 while True:
11 choose = input(
"please input you want to do function.such as: \033[32;1m'add account'\033[0m,\033[32;1m"
12 "'change user quota'\033[0m,\033[32;1m'frozen account'\033[0m.".capitalize())
13 if choose ==
'add account':
14 add_account = input(
'Please enter the account you want to add.')
15 add_passworld = input(
'Please enter the password you want to add.')
16 print(
'\033[33;1mRepeat for safety reasons.\033[0m')
17 add_again_account = input(
'Please enter the account you want to add.')
18 add_again_passworld = input(
'Please enter the password you want to add.')
19 if add_account == add_again_account
and add_passworld ==
add_again_passworld:
20 add_money_choose = input(
'Do you want to initialize the amount?')
21 if add_money_choose !=
'N':
22 while True:
23 add_money = input(
'Please enter amount. ')
24 if add_money.isdigit():
25 add_money =
int(add_money)
26 account_sample.account_initial(add_account,add_passworld,add_money)
27 break
28 else:
29 print(
'\033[31;1mPlease enter number.\033[0m')
30 else:
31 account_sample.account_initial(add_account,add_passworld)
32 else:
33 print(
'\033[36;1mAccount or password error!\033[0m')
34 elif choose ==
'change user quota':
35 from core
import accounts
36 change_account = input(
"Please enter you want to change account .")
37 change_money = input(
"Please enter the amount you want to change.")
38 accounts.quota(change_account,change_money)
39 elif choose ==
'frozen account':
40 from core
import accounts
41 frozen_account =input(
"Please enter you want to frozen account.")
42 accounts.frozen_account(frozen_account)
43 elif choose ==
'q'or choose ==
'Q':
44 break
45 else:
46 print(
'\033[37;1mplease enter legal character.\033[0m')
manager.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Author:Source
4 import json,sys,os
5 site_core = os.path.dirname(os.path.abspath(
__file__))
6 sys.path.append(site_core)
7 import small_function
8 def account():
9 '打印账户名'
10 with open(
'C:/Users/ys106/PycharmProjects/Source/day4/homework/ATM_Program/atm/db/accounts/account_total.json',
'r')as f:
11 print_account =
json.load(f)
12 print(
"These are the account names:",print_account)
13 return print_account
14 def quota(acco,money):
15 '改变账户额度'
16 account_sum =
account()
17 if acco
in account_sum:
18 with open(
'C:/Users/ys106/PycharmProjects/Source/day4/homework/ATM_Program/atm/db/accounts/%s.json'