Answer the question
In order to leave comments, you need to log in
Working with pickle. How to output all dictionary data from a file?
How to output all dictionary data from a file? The code:
import pickle
f = open('users.txt', 'rb')
e = pickle.load(f)
import pickle
f = open('users.txt', 'rb')
e = pickle.load(f)
while e.keys() != '':
print(pickle.load(f))
Answer the question
In order to leave comments, you need to log in
Try like this:
from pickle import dumps, load
def store(arg):
f = open('file.txt', 'w')
f.write(dumps(arg))
f.close()
def extract():
f = open('file.txt', 'r')
result = load(f)
f.close()
return result
d0 = {'one': 1, 'two': 2}
store(d0)
d1 = extract()
print d1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question