the below is my entire program .. i just don't know were am I going wrong
it keeps on telling that the process is eing used by some other file ...I just don't understand
please help me out as I need to submit this within two days time
import os
import pickle
password=123
l=input("Enter Password :")
if l==password:
print"--------Welcome Admin--------"
class new:
def __init__(self,a,b,c):
self.acno=a
self.acna=b
self.ini=c
def display(self):
print self.acno,self.acna,self.ini
def form(): # creating new account holders
print" ---New Account Entry Form--- "
n=input("Enter the no. Forms")
f1=open("new.dat","ab")
for i in range (n):
a=input("Enter The Account No:")
b=raw_input("Enter The Name of The Account Holder:")
c=input("Enter The Initial Amount (>=5000 ):")
if c<5000:
print "Initial Amount Too Low"
c=input("Enter The Initial Amount (>=5000 ):")
e=new(a,b,c)
pickle.dump(e,f1)
f1.close()
print"--------Account Created Successfully--------------"
def depo():#depositing amount in the account
print" ---- Account Deposition Form ---- "
p=input("Enter the Account Number:")
f1=open("new.dat","rb")
f2=open("dep.dat","wb")
amt=input("Enter the Amount to Deposit :")
try:
while True:
s=pickle.load(f1)
if s.acno==p:
s.ini+=amt
pickle.dump(s,f2)
except EOFError:
f1.close()
f2.close()
print"Amount Deposited Successfully"
os.remove("new.dat")
os.rename("dep.dat","new.dat")
def withdraw():#to withdraw
print " Account Transaction Form "
p=input("enter the account n:")
f2=open("new.dat","rb")
f3=open("f2.dat","wb")
amt=input("Enter the amount to Withdraw:")
try:
while True:
s=pickle.load(f2)
if s.acno==p:
if s.ini>amt or s.ini==amt :
s.ini-=amt
pickle.dump(s,f3)
print "Amount Withdrawed"
elif s.ini<amt:
print "No sufficient balance "
else:
print " Account no. invalid"
except EOFError:
f2.close()
f3.close()
os.remove("new.dat")
os.rename("f2.dat","new.dat")
def balance():#check the balance
print" Balance Amount Details"
p=input("Enter the Account Number:")
f3=open("new.dat","rb")
try:
while True:
s=pickle.load(f3)
if s.acno==p:
print "the Balance Amount for Acc. no. ",p,"is :", s.ini
except EOFError:
f3.close()
def displa():#display all the account holders
print " All Account Holders List "
f1=open("new.dat","rb")
try :
while True:
k=pickle.load(f1)
k.display()
except EOFError:
f1.close()
def dele(): # to delete the account holder error here
print " Account Deletion Form"
f1=open("new.dat","rb")
f2=open("tnew.dat","wb")
try:
e=pickle.load(f1)
no=input("Enter the Account No:")
if e.acno!=no:
pickle.dump(e,f2)
except EOFError:
f2.close()
f1.close()
os.remove("new.dat") #error here
os.rename("tnew.dat","new.dat") # error here
f1.close()
while True:
print"-----------------------------------------------------------------------------------------------------------------"
print" Bank Management System"
print" "
print"---Main Menu--- :"
print"1. New account"
print"2. Deposit amount"
print"3. Withdraw amount"
print"4. Balance account"
print"5. All Account Holders List "
print"6. Close An Account"
print"7. Exit"
choice=input("Enter Your Option (1-7):")
if choice==1:
form()
elif choice==2:
depo()
elif choice==3:
withdraw()
elif choice==4:
balance()
elif choice==5:
displa()
elif choice==6:
dele()
else:
print "-------Login In Later----------"
break
else:
print "PASSWORD Incorrect"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…