Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pickle.dumps takes an object as a parameter and returns a string representation (dumps is short for “dump string”):
- >>> import pickle
- >>> t = [1, 2, 3]
- >>> pickle.dumps(t)
- '(lp0\nI1\naI2\naI3\na.'
- # The format isn’t obvious to human readers; it is meant to be easy for pickle to interpret.
- # pickle.loads (“load string”) reconstitutes the object:
- >>> t1 = [1, 2, 3]
- >>> s = pickle.dumps(t1)
- >>> t2 = pickle.loads(s)
- >>> print t2
- [1, 2, 3]
- # Although the new object has the same value as the old, it is not the same object:
- >>> t1 == t2
- True
- >>> t1 is t2
- False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement