Challenge

Project 1 - English Dictionary App & Library Book Management System

english dictionary app

#1 Database -software interface

import pickle#serialization package

import os

def savedictionary(tmp_dict):

this function recives a python dictionary,and saves it to a serialized file words.txt

'''

try:

#'wb' means open file with writing binary mode with open('words.txt', 'wb') as dictionary:

pickle,dump(tmp_dict,dictionary)

#dictionary = open('words.txt','wb')

#pickle.dump(tmp_dict,dictionary)

#dictionary.close() print("SUCCESS:writing to dictionary words.txt'')

except exception as e:

print(f"ERROR:{e}")

defgetdictionary():

''' this function returns a python dictionary, after de-serializing the file words.txt ''' try:

#'rb' means open file with reading binary mode withopen('words.txt','rb') as dictionary: tmp_dict = pickle.load(dictionary)

print(''success:reading from dictionary words.txt'') return tmp_dict

except exception as e:print(f"ERROR:{e}'')

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.