This system all uses the Python basic knowledge reality
Program Structure
Atm
|--readme
|--ATM #ATM主程序目录
| |--__init__.py
| |--atm.py #ATM执行程序
| |__manage.py #ATM管理端--management portal for adding users, modifying quotas, and freezing accounts
| |
| |--conf #配置文件
| | | |--__init__.py
| | | |--setting.py
| |
| |--core #主要程序逻辑
| | | |--__init__.py
| | | |--accounts.py #用于从文件里加载和存储账户数据
| | | |--auth.py #用户认证模块
| | | |--db_handler.py #数据库连接引擎
| | | |--logger.py #日志记录模块
| | |--main.py #主逻辑交互程序------> User Portal to realize the functions of mall, cash withdrawal, repayment, consumption (swipe), etc.
| | |--transaction.py #记账, pay back money, withdraw money and all other actions related to account amount
| |
| |--db #用户数据存储的地方
| | | |--__init__.py
| | | |--account_sample.py #生成一个初始账户数据, save this data as a file with this account ID, and put it in the accounts directory
| | | |--accounts #存各个用户的账户数据, a user a file
| | | | |--1234.json
| | |
| |--log #日志目录
| |--__init__.py
| |--access.log #用户访问和操作的相关日志
| |--transaction.log #所有交易日志
|
|--shopping_mall #电子商城程序---> Functions in main.py
Set the frame, the code will be good to write, first of all to consider the configuration file writing
Import OS
Base_dir = Os.path.dirname (Os.path.dirname (Os.path.abspath (__file__)))
#数据库信息
DATABASE = {
' Engine ': ' File_storage ',
' Name ': ' Accounts ',
' Path ': "%s\db"%base_dir
}
#用户操作类型
Oporation_type = {
' 1 ': ' Mall ',
' 2 ': ' Account ',
' 3 ': ' Cash ',
' 4 ': ' Refund ',
' 5 ': ' Transfer ',
' 6 ': ' Consumption ',
' 7 ': ' Exit '
}
#算法
Algorithm = {
' Mall ': {' action ': ' No ', ' Interset ': 0},
' account ': {' action ': ' No ', ' Interset ': 0.05},
' Cash ': {' action ': ' Minus ', ' Interset ': 0.05},
' Refund ': {' action ': ' Add ', ' Interset ': 0},
' Transfer ': {' action ': ' Minus ', ' Interset ': 0},
' consumption ': {' action ': ' Minus ', ' Interset ': 0.02},
' exit ': {' action ': ' No ', ' Interset ': 0}
}
#日志信息--Database operations log
LogFile = {
' File ': ' Data ',
' Name ': ' Access ',
' Path ': "%s\logs"%base_dir
}
#日志信息-Account information record
Logfile1 = {
' File ': ' Trans ',
' Name ': ' Transaction ',
' Path ': "%s\logs"%base_dir
}
#购物车相关信息
Shop = {
' File ': ' Mall ',
' Name ': ' Mall ',
' Path ': "%s\docs"%base_dir
}
#商城信息
MALL = {
' File ': ' Trolley ',
' Name ': ' Trolley ',
' Path ': "%s\docs"%base_dir
}
The ATM-1 of Python basics