I'm making a Animal guessing game and i finish the program but i want to add pickle so it save questions to disk, so they won't go away when the program exits. Anyone can help?
Save an object containing the game state before the program exits:
pickle.dump(game_state, open('gamestate.pickle', 'wb'))
Load the object when the program is started:
game_state = pickle.load(open('gamestate.pickle', 'rb'))
In your case, game_state may be a list of questions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With