I'm trying to make an address book on the book Byte of Python.
Trying to delete a contact from a file:
def delete_person(self): f = open('mybook.txt', 'ab+') allcontacts = pickle.load(f) deluser = input('Введите имя того, кого хотите удалить?') del allcontacts[deluser] f = allcontacts pickle.dump(PhoneBook.mybook, f) f.close()
What could be the problem? I tried to insert different modes of reading and writing to the file.
Gives an error message:
Traceback (most recent call last): File "C:/PythonWork/Kate/phonebookclassi.py", line 81, in <module> phonebook.delete_person() File "C:/PythonWork/Kate/phonebookclassi.py", line 36, in delete_person allcontacts = pickle.load(f) EOFError: Ran out of input
'rb'
. - mkkikPickle
, it seems, does not support anything exceptwb
/rb
. - mkkik