pickle - list to file to list

PHOTO EMBED

Tue Mar 07 2023 13:55:04 GMT+0000 (Coordinated Universal Time)

Saved by @quaie #python

If you are just trying to serialize a list to disk for later use by the same python app, you should be pickleing the list --> https://docs.python.org/3/library/pickle.html

```
import pickle

with open('outfile', 'wb') as fp:
    pickle.dump(itemlist, fp)
```

To read it back:

```
with open ('outfile', 'rb') as fp:
    itemlist = pickle.load(fp)
```
content_copyCOPY

https://stackoverflow.com/questions/899103/writing-a-list-to-a-file-with-python-with-newlines