Hey all,
How do I fix the following error:
<begin error>
File to load: passcard.txt
Traceback (most recent call last):
File "D:\Python24\password.py", line 82, in -toplevel- load_file(sitelist,filename) File "D:\Python24\password.py", line 51, in load_file [site,ID,passcard] = string.split(in_line,",") File "D:\Python24\lib\string.py", line 292, in split return s.split(sep, maxsplit) AttributeError: 'list' object has no attribute 'split' <end error>
<begin code>
#This is for a password protected program to store passwords.
import string password = "hello" sitelist = {} def main_menu():
print "1) Add a login info card" print "2) Lookup a login info card" print "3) Remove a login info card" print "4) Print Login info list" print "5) Load info" print "6) Save info" print "9) Exit" def add_site():
print "Add a login info card" site = raw_input("Site: ") ID = raw_input("User ID: ") passcard = raw_input("Password: ") sitelist[site] = [ID,passcard] def lookup_site():
print "Lookup a login info card" site = raw_input("Site: ") if sitelist.has_key(site): print "The ID is: ",sitlist[site][0] print "The password is: ",sitelist[site][1] else: print site," was not found." def remove_site():
print "Remove a login info card" site = raw_input("Site: ") if sitelist.has_key(site): del sitelist[site] else: print site," was not found." def print_login_info():
print "Login Info" for site in sitelist.keys(): print "Site: ",site," \tID: ",sitelist[site][0]," \tPassword: ",sitelist[site][1],"\n" def load_file(sitelist,filename):
in_file = open(filename,"r") while 1: in_line = in_file.readlines() if in_line == "": break in_line = in_line[:-1] [site,ID,passcard] = string.split(in_line,",") sitelist[site] = sitelist def save_file(sitelist,filename):
out_file = open(filename,"w") for site in sitelist.keys(): out_file.write(site+","+sitelist[site][0]+","+sitelist[site][1]+"\n") out_file.close() print "The Password Program"
print "By Nathan Pinno" answer = raw_input("What is the password? ") while password != answer: print "The password is incorrect." answer = raw_input("What is the password? ") print "Welcome to the second half of the program."
while 1: main_menu() menu_choice = int(raw_input("Choose an option (1-6, or 9: ")) if menu_choice == 1: add_site() elif menu_choice == 2: lookup_site() elif menu_choice == 3: remove_site() elif menu_choice == 4: print_login_info() elif menu_choice == 5: filename = raw_input("File to load: ") load_file(sitelist,filename) elif menu_choice == 6: filename = raw_input("Filename to save as: ") save_file(sitelist,filename) elif menu_choice == 9: break else: print "That's not an option!" print "Have a nice day!" <end code> Thanks in advance,
Nathan Pinno,
|
BEGIN:VCARD VERSION:2.1 N:Pinno;Nathan;Paul;Mr. FN:Pinno, Nathan Paul ORG:Woffee;Executive TITLE:Owner/operator TEL;CELL;VOICE:7806085529 ADR;WORK:;President/CEO LABEL;WORK:President/CEO ADR;HOME:;;Box 1783;Camrose;Alberta;T4V1X7;Canada LABEL;HOME;ENCODING=QUOTED-PRINTABLE:Box 1783=0D=0ACamrose, Alberta T4V1X7=0D=0ACanada X-WAB-GENDER:2 URL;HOME:http://falcon3166.tripod.com URL;WORK:http://falcon3166.tripod.com/Woffee.htm BDAY:19850221 EMAIL;PREF;INTERNET:[EMAIL PROTECTED] EMAIL;INTERNET:[EMAIL PROTECTED] EMAIL;INTERNET:[EMAIL PROTECTED] EMAIL;INTERNET:[EMAIL PROTECTED] REV:20050804T015838Z END:VCARD
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor