_DeCoDe

adress book.py

Jun 12th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. #Address book
  2. import pickle
  3.  
  4.  
  5. add = pickle.load(open('/sdcard/Download/dump.txt', 'rb'))
  6. def man ():
  7.     while True:
  8.         menu = int(input("1) Cauta o adresa\n2)Insereaza o adresa\n3)exit\n:"))
  9.         if menu == 2:
  10.             adaugaAdresa()
  11.         if menu == 1:
  12.             cautaAdresa()  
  13.  
  14. def cautaAdresa():
  15.     nume = input("Introduce numele complet: ")
  16.     if nume in add.keys():
  17.         print(add[nume])    
  18. def adaugaAdresa():
  19.     nume = input("Introduce numele complet: ")
  20.     adresa = input("Introduce adresa completa: ")
  21.     add[nume] = adresa
  22.     pickle.dump(add, open('/sdcard/Download/dump.txt', 'wb'))
  23.     print (add)
  24.    
  25.  
  26. if __name__ == '__main__':
  27.     man ()
Advertisement
Add Comment
Please, Sign In to add comment