私は銀行システムを作成するために私が配偶者であるプロジェクトに取り組んでいます。私はプログラムを完了し、それは完全に動作します私が助けが必要な唯一の問題は、サインアップのためのユーザーデータを格納する登録フォームを作成する方法と、txtファイルからのログイン用のデータを読み取ることです。どのように私はpythonで.txtファイルにuseresデータを格納する登録フォームを作るのですか?
=
balance = 100
def log_in():
tries = 1
allowed = 5
value = True
while tries < 5:
print('')
pin = input('Please Enter You 4 Digit Pin: ')
if pin == '1234':
print('')
print(" Your Pin have been accepted! ")
print('---------------------------------------------------')
print('')
return True
if not len(pin) > 0:
tries += 1
print('Username cant be blank, you have,',(allowed - tries),'attempts left')
print('')
print('---------------------------------------------------')
print('')
else:
tries += 1
print('Invalid pin, you have',(allowed - tries),'attempts left')
print('')
print('---------------------------------------------------')
print('')
print("To many incorrect tries. Could not log in")
ThankYou()
def menu():
print (" Welcome to the Python Bank System")
print (" ")
print ("Your Transaction Options Are:")
print ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print ("1) Deposit Money")
print ("2) Withdraw Money")
print ("3) Check Balance")
print ("4) Quit Python Bank System.pyw")
def option1():
print (' Deposit Money' )
print('')
print("Your balance is £ ",balance)
Deposit=float(input("Please enter the deposit amount £ "))
if Deposit>0:
forewardbalance=(balance+Deposit)
print("You've successfully deposited £", Deposit, "into your account.")
print('Your avalible balance is £',forewardbalance)
print('')
print('---------------------------------------------------')
service()
else:
print("No deposit was made")
print('')
print('---------------------------------------------------')
service()
def option2():
print (' Withdraw Money' )
print('')
print("Your balance is £ ",balance)
Withdraw=float(input("Enter the amount you would like to Withdraw £ "))
if Withdraw>0:
forewardbalance=(balance-Withdraw)
print("You've successfully withdrawed £",Withdraw)
print('Your avalible balance is £',forewardbalance)
if Withdraw >= -100:
print("yOU ARE ON OVER YOUR LIMITS !")
else:
print("None withdraw made")
def option3():
print("Your balance is £ ",balance)
service()
def option4():
ThankYou()
def steps():
Option = int(input("Enter your option: "))
print('')
print('---------------------------------------------------')
if Option==1:
option1()
if Option==2:
option2()
if Option==3:
option3()
if Option==4:
option4()
else:
print('Please enter your option 1,2,3 or 4')
steps()
def service():
answer = input('Would you like to go to the menu? ')
answercov = answer.lower()
if answercov == 'yes' or answercov == 'y':
menu()
steps()
else:
ThankYou()
def ThankYou():
print('Thank you for using Python Bank System v 1.0')
quit()
log_in()
menu()
steps()
私は私のプログラムは、サインアップのためのユーザー・データを格納し、.txtファイルからのログインのためのデータを読み込みます登録フォームを持っていることを期待しています。
.txtはデータを格納するのに適していませんが、現在のコードでは複雑です。まず、最後の関数であるThankYou()は、カーネルを閉じて(line quit())終了したすべてを消去します。第二に、関数のどれもがどんな値も返しません。またはグローバル値を使用しないでください。第3に、データフレームでは、severalsユーザーを持つことができます。ピンがユーザーに対応するかどうかを確認し、データフレーム内の自分のアカウントにアクティビティを登録します。 – Mathieu