Save data on python script using a python script -
suppose have file test.py
. import using interactive interpreter, add strings data
in file. how go saving file afterwards? closing interpreter keeps test.py
in original state. i've looked @ couple questions told me use pickle
. however, 1 of issues pointed out in documentation pickle
not readable @ all. i've tried using open
function, i'm not sure how go using effectively.
bottom line, how take data python script, add or remove parts of it, , save use afterwards?
test.py
:
# test.py data = []
python shell
:
>>> import test >>> test.data.append("hello there!") >>> test.data ['hello there!']
there no way work python "data" files while saving them , preserving them scripts.
while pickle
lacks human readability, it's become choice in handling data , saving them. current program writing, future programs come.
while pickle lacks human readability, @ least machine readable, meaning won't have go through loads of useless work. it's compromise better.
thanks helped me come pickle.
Comments
Post a Comment