Reputation: 27
I imported pickle from copyreg. I then use the attribute dumps to convert a dictionary into bytes b'\x80\x04...' but it results in the error shown below:
from copyreg import pickle
d={"name":value}
d=pickle.dumps(d)
Error:
AttributeError: 'function' object has no attribute
Upvotes: 1
Views: 1296
Reputation: 63
Your import seems incorrect. It should be:
from pickle import dumps
d = {..}
d = dumps(d)
Upvotes: 2
Reputation: 27
I imported from the wrong library. The code should have been:
import pickle
d={...}
d=pickle.dumps(d)
Upvotes: 0