Δημοσιεύτηκε: 30 Σεπ 2011, 23:24
από clepto
όταν πατάω 1 δεν κάνει τίποτα
Κώδικας: Επιλογή όλων
#!/bin/python3

import os.path
import pprint # "Pretty print"
try:
import cPickle as pickle
except ImportError:
import pickle

pickle_file = "crypt.db"
pickle_dict = dict()

# If pickle file exists
if os.path.exists(pickle_file):
with open(pickle_file, "rb") as f:
pickle_dict = pickle.load(f)


def save():
pickle.dump(pickle_dict, f) # dump the object to a file
f.close()


def write( a_dict ):
name = input("ονομα; ")
pickle_dict["name"] = "name"
with open(pickle_file, "wb") as f:
pickle.dump(pickle_dict, f)
save()


def delete():
name = input("ονομα; ")
pickle_dict.pop("name")
save()

def menu():
n = input("τι θελετε να κανετε; ")
if n == 1:
write()
elif n == 2:
delete()

menu()