+ 1

Is there a better way to save data in Python?

Today, i was trying to save a string in a file and it worked, but i was thinking is there another way to do this? Is this the best way? or is there another way that is better? and how do i save things like variables? Please explain why something is better and why this is bad or good.

18th Aug 2017, 6:56 PM
Joel Burleson
Joel Burleson - avatar
2 Antworten
+ 7
You can always dump() it with pickle. Works like a charm and saves/restores your data objects exactly how you want them. I prepared an example with a dictionary, but it works alright with much more complex data structures, too. https://code.sololearn.com/cNXRdhIOg17U/?ref=app
18th Aug 2017, 7:03 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
Thank you for answering my question i will look into pickle.
18th Aug 2017, 7:04 PM
Joel Burleson
Joel Burleson - avatar