濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > python實(shí)現(xiàn)銀行賬戶系統(tǒng)

python實(shí)現(xiàn)銀行賬戶系統(tǒng)

熱門標(biāo)簽:深圳網(wǎng)絡(luò)外呼系統(tǒng)代理商 外呼系統(tǒng)前面有錄音播放嗎 千呼ai電話機(jī)器人免費(fèi) 鎮(zhèn)江人工外呼系統(tǒng)供應(yīng)商 騰訊地圖標(biāo)注有什么版本 400電話辦理費(fèi)用收費(fèi) 申請(qǐng)辦個(gè)400電話號(hào)碼 高德地圖標(biāo)注字母 柳州正規(guī)電銷機(jī)器人收費(fèi)

Python編寫一個(gè)簡(jiǎn)易銀行賬戶系統(tǒng),供大家參考,具體內(nèi)容如下

文章中主要涉及的方法是Python中的open(filename, ‘r')以讀的方式打開文件open(filename, ‘w')以寫的方式打開文件我們用for * in *讀取文件中的數(shù)據(jù)或者寫入文件數(shù)據(jù) 用dict(eval(list2))方法來把字符串轉(zhuǎn)化為字典。

詳細(xì)代碼如下

import math
import re

def main(): # 主函數(shù)
 select = True
 while (select):
 menu()
 start_int = input("請(qǐng)選擇你您想要操作功能的序號(hào):")
 if start_int == "12":
 select = False
 print("你已經(jīng)退出系統(tǒng)歡迎下次在來")
 elif start_int == "4":
 insert()
 elif start_int == "5":
 login()
 elif start_int == "6":
 show()
 elif start_int == "11":
 delete()
 elif start_int == "7":
 revise()
 elif start_int == "8":
 deposit()
 elif start_int == "9":
 getMoney()
 elif start_int == "10":
 UseMoney()



def menu(): # 菜單顯示
 print("1========銀行存取錢系統(tǒng)========")
 print("2===========================")
 print("3===========功能菜單===========")
 print("4=========注冊(cè)個(gè)人信息==========")
 print("5============登入=============")
 print("6=========查詢個(gè)人信息==========")
 print("7=========修改個(gè)人賬戶==========")
 print("8============存錢=============")
 print("9============取錢=============")
 print("10=========顯示年收益==========")
 print("11========注銷個(gè)人信息==========")
 print("12===========退出=============")


filename = "Bank.txt" # 定義保存用戶信息的文件名

def save(Bank): # 創(chuàng)建文件方法
 try:
 Bank_txt = open(filename, "a")
 except Exception as e:
 Bank_txt = open(filename, "w")
 for info in Bank:
 Bank_txt.write(str(info) + "\n")
 Bank_txt.close()


def insert(): # 注冊(cè)方法
 BankList = [] # 保存用戶信息列表
 mark = True # 是否繼續(xù)添加
 while mark:
 id = input("請(qǐng)輸入您的ID密碼(如1001):")
 if not id:
 break
 name = input("請(qǐng)輸入姓名")
 if not name:
 break
 try:
 deposit = int(input("輸入你要存款的金額"))
 if deposit == 0:
 break
 except:
 print("輸入無(wú)效,不是輸入整型數(shù),請(qǐng)重新輸入")
 continue
 Bank = {"id": id, "name": name, "deposit": deposit}
 BankList.append(Bank)
 mark = False
 save(BankList)
 print("注冊(cè)成功")


global g_select
g_select = 0
global Username
global Userpassword


def login(): # 登入方法
 global Username
 global g_select
 global g_BankQuery
 global Userpassword
 g_BankQuery = []
 Username = str(input("請(qǐng)輸入您的用戶名"))
 Userpassword = str(input("請(qǐng)輸入您的密碼"))
 file = open(filename, 'r')
 Bank = file.readlines() # 讀取全部?jī)?nèi)容
 for list in Bank:
 d = dict(eval(list)) # 字符轉(zhuǎn)化為字典
 if d['name'] == Username and d['id'] == Userpassword:
 g_BankQuery.append(d)
 print("登入成功!")
 g_select = 1
 else:
 pass
 if not g_BankQuery:
 g_select = 0
 print("登入失敗請(qǐng)先注冊(cè)!")
 else:
 pass




def show(): # 查詢個(gè)人信息
 if g_select == 1:
 format_title = "{:^6}{:^12}"
 print(format_title.format("名字", "存款"))
 format_date = "{:^6}{:^12}"
 for info in g_BankQuery:
 print(format_date.format(str(info.get('name')), str(info.get('deposit'))))
 else:
 print("請(qǐng)先登入!")


def delete(): # 刪除個(gè)人賬戶方法
 global g_BankQuery
 cz = []
 global g_select
 choose = 0
 if g_select == 1:
 while choose  3:
 username = str(input("請(qǐng)輸入你姓名"))
 userpassword = str(input("請(qǐng)輸入您的密碼"))
 file = open(filename, 'r')
 Bank = file.readlines() # 讀取全部?jī)?nèi)容
 for list in Bank:
 d = dict(eval(list)) # 字符轉(zhuǎn)化為字典
 if d['name'] == username and d['id'] == userpassword:
  cz.append(d)
  file.close()
  choose = 3
  NewBank = open(filename, 'w') # 以寫的方式打開文件
  for list2 in Bank:
  d2 = dict(eval(list2)) # 字符轉(zhuǎn)化為字典
  if d2['name'] != username and d2['id'] != userpassword:
  NewBank.write(str(d2) + "\n")
  else:
  pass
 else:
  pass
 if not cz:
 choose = choose + 1
 if choose == 3:
  g_select = 0
  print("請(qǐng)重新登入!")
 else:
  print("用戶名或者密碼錯(cuò)誤,請(qǐng)重新輸入你還有:" + str(3 - choose) + "機(jī)會(huì)")
 else:
 g_BankQuery.clear()
 g_select = 0
 print("您的個(gè)人信息已經(jīng)注銷")

 else:
 print("請(qǐng)先登入!")

def revise(): # 修改個(gè)人賬戶方法
 cz = []
 global g_select
 if g_select == 1:
 username = input("請(qǐng)輸入您的用戶名:")
 userpassword = input("請(qǐng)輸入您的密碼:")
 file = open(filename, 'r')
 Bank = file.readlines() # 讀取全部?jī)?nèi)容
 for list in Bank:
 d = dict(eval(list)) # 字符轉(zhuǎn)化為字典
 if d['name'] == username and d['id'] == userpassword:
 cz.append(d)
 file.close()
 NewBank = open(filename, 'w') # 以寫的方式打開文件
 for list2 in Bank:
  d2 = dict(eval(list2)) # 字符轉(zhuǎn)化為字典
  if d2['name'] == username and d2['id'] == userpassword:
  d2['name'] = input("輸入您的新名字:")
  d2['id'] = input("輸入您的新密碼:")
  NewBank.write(str(d2) + "\n")
  print("修改成功,請(qǐng)重新登入!")
  g_select = 0
  else:
  NewBank.write(str(d2) + "\n")
 else:
 pass
 if not cz:
 print("你輸入的密碼或者用戶名有誤請(qǐng)重新登入")
 g_select = 0
 else:
 pass
 else:
 print("請(qǐng)先登入!")

def deposit(): # 存錢方法
 global g_BankQuery
 global g_select
 cz = []
 if g_select == 1:
 money = int(input("請(qǐng)輸入你要存多少錢:"))
 file = open(filename, 'r')
 Bank = file.readlines() # 讀取全部?jī)?nèi)容
 for list in Bank:
 d = dict(eval(list)) # 字符轉(zhuǎn)化為字典
 if d['name'] == Username and d['id'] == Userpassword:
 cz.append(d)
 file.close()
 NewBank = open(filename, 'w') # 以寫的方式打開文件
 for list2 in Bank:
  d2 = dict(eval(list2)) # 字符轉(zhuǎn)化為字典
  if d2['name'] == Username and d2['id'] == Userpassword:
  d2['deposit'] = str(int(d2['deposit']) + money)
  NewBank.write(str(d2) + "\n")
  print("儲(chǔ)存成功!")
  g_BankQuery.clear()
  g_BankQuery.append(d2)
  else:
  NewBank.write(str(d2) + "\n")
 else:
 pass
 else:
 print("請(qǐng)先登入!")

def getMoney(): # 取錢方法
 global g_select
 global g_BankQuery
 cz = []
 if g_select == 1:
 money = int(input("請(qǐng)輸入你要取多少錢:"))
 file = open(filename, 'r')
 Bank = file.readlines() # 讀取全部?jī)?nèi)容
 for list in Bank:
 d = dict(eval(list)) # 字符轉(zhuǎn)化為字典
 if d['name'] == Username and d['id'] == Userpassword:
 cz.append(d)
 if money > int(d['deposit']):
  print("您的余額不足")
 else:
  file.close()
  NewBank = open(filename, 'w') # 以寫的方式打開文件
  for list2 in Bank:
  d2 = dict(eval(list2)) # 字符轉(zhuǎn)化為字典
  if d2['name'] == Username and d2['id'] == Userpassword:
  d2['deposit'] = str(int(d2['deposit']) - money)
  NewBank.write(str(d2) + "\n")
  print("取錢成功!")
  g_BankQuery.clear()
  g_BankQuery.append(d2)
  else:
  NewBank.write(str(d2) + "\n")
 else:
 pass
 else:
 print("請(qǐng)先登入!")


def UseMoney(): # 利息計(jì)算
 UM = True
 while UM:
 try:
 money = float(input("請(qǐng)輸入你要投資理財(cái)多少錢:"))
 year = int(input("請(qǐng)你輸入你要儲(chǔ)存多少年:"))
 except:
 print("請(qǐng)你輸入整數(shù)年份!")
 if 0  year = 3:
 profitmargin = 0.03
 elif 3  year = 5:
 profitmargin = 0.04
 elif 5  year = 10:
 profitmargin = 0.06
 elif year > 10:
 profitmargin = 0.08
 if money  0 or year = 0:
 print("您的本金不能少于0元或者年份不能少于0年")
 else:
 UM = False
 profit = round(money * year * profitmargin, 3)
 print("你儲(chǔ)存:" + str(year) + "年將獲得的利潤(rùn)會(huì)等于:" + str(profit) + "元本金加利潤(rùn)會(huì)等于:" + str(profit + money) + "元")


if __name__ =="__main__":

運(yùn)行圖片:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • python實(shí)現(xiàn)銀行實(shí)戰(zhàn)系統(tǒng)
  • Python實(shí)現(xiàn)銀行賬戶資金交易管理系統(tǒng)
  • python銀行系統(tǒng)實(shí)現(xiàn)源碼
  • python實(shí)現(xiàn)簡(jiǎn)單銀行管理系統(tǒng)
  • Python銀行系統(tǒng)實(shí)戰(zhàn)源碼
  • python實(shí)現(xiàn)銀行管理系統(tǒng)
  • Python實(shí)現(xiàn)的銀行系統(tǒng)模擬程序完整案例
  • Python3 適合初學(xué)者學(xué)習(xí)的銀行賬戶登錄系統(tǒng)實(shí)例

標(biāo)簽:大慶 烏蘭察布 烏蘭察布 哈爾濱 平頂山 海南 合肥 郴州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《python實(shí)現(xiàn)銀行賬戶系統(tǒng)》,本文關(guān)鍵詞  python,實(shí)現(xiàn),銀行,賬戶,系統(tǒng),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《python實(shí)現(xiàn)銀行賬戶系統(tǒng)》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于python實(shí)現(xiàn)銀行賬戶系統(tǒng)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    栖霞市| 阿克苏市| 曲周县| 德江县| 商丘市| 正阳县| 乌兰察布市| 丰都县| 内江市| 嫩江县| 海盐县| 富民县| 连城县| 华阴市| 鄂伦春自治旗| 兴安盟| 云安县| 平罗县| 奉贤区| 南澳县| 迁安市| 新乡市| 永清县| 任丘市| 克拉玛依市| 牙克石市| 邮箱| 华宁县| 游戏| 错那县| 黔西县| 奉化市| 东海县| 承德县| 石屏县| 永新县| 股票| 陇南市| 武义县| 沅陵县| 石河子市|