1

I am an beginner of python and I am doing an exercise to create a address-book program. And now I have some problems.

The information is stored by 'pickle.dump'. I try to insert 2 information to the file 2 times

f = open(contacts, 'wb')
pickle.dump(ab, f)
f.close()

f = open(contacts, 'ab')
pickle.dump(ab, f)
f.close()

but I can't 'load' these information at once and I can read these information in for loop.

f = open(file, 'rb')
for i in range(2):
    stroed = pickle.load(f)
    print(stroed)

I don't know how to use while loop to read all information and end while loop at the end of the file.

Can you help me, please?

near99
  • 13
  • 3
  • 1
    Possible dublicate of http://stackoverflow.com/questions/20716812/saving-and-loading-multiple-objects-in-python-pickle-file – Stanislav Ivanov Oct 20 '16 at 15:11
  • Welcome to StackOverflow. Be carefull when to write a message to be understandable. You should write sample of code instead of uploading a picture. Your link may disappear after a while and we can copy and paste your code more easily. – Thomas Betous Oct 20 '16 at 15:45

0 Answers0