Browse Source

Pickle

pull/10/head
Jure Šorn 5 years ago
parent
commit
616cef5659
1 changed files with 5 additions and 4 deletions
  1. 9
      README.md

9
README.md

@ -952,10 +952,11 @@ Pickle
------
```python
>>> import pickle
>>> favorite_color = {'lion': 'yellow', 'kitty': 'red'}
>>> pickle.dump(favorite_color, open('data.p', 'wb'))
>>> pickle.load(open('data.p', 'rb'))
{'lion': 'yellow', 'kitty': 'red'}
>>> P = collections.namedtuple('P', 'x y')
>>> points = [P(0, 0), P(1, 1), P(2, 2)]
>>> pickle.dump(points, open('points.p', 'wb'))
>>> pickle.load(open('points.p', 'rb'))
[P(x=0, y=0), P(x=1, y=1), P(x=2, y=2)]
```

Loading…
Cancel
Save