Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to save a class object to a file?
i was using json to save some data for my game. While I was trying to save I noticed I got an error on serializing the Player class. I could save all the stats of the player, but that would be a hassle. Is there a way I can save the Player class to a file.
Age Doesn't Matter, Your Passion Does
- Shreya Jain
Pickle or Shelve.

If it's just one object (the player), then Pickle. Shelve is sort of like a dictionary interface for using Pickle with a lot of different things.
metulburr likes this post
It should be noted that pickling can be dangerous. If you are just using it for a local game, then you dont have to worry about anything.
micseydel likes this post

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  save content of table into file atlass218 8 194 Yesterday, 04:02 PM
Last Post: Gribouillis
  class returns NoneType Object istemihan 0 68 Aug-12-2019, 11:47 AM
Last Post: istemihan
  Object and type class Uchikago 2 131 Jul-28-2019, 10:35 AM
Last Post: DeaD_EyE
  Display output in readable format and save hnkrish 1 91 Jul-19-2019, 09:29 AM
Last Post: Larz60+
  How to save latest time stamp in a file? redwood 12 717 Jul-11-2019, 11:03 AM
Last Post: redwood
  Return a value when I equal an object from a class ihouses 4 197 Jul-10-2019, 02:44 AM
Last Post: SheeppOSU
  How can I save Python dictionaries in Matlab? jlostinco 1 213 Jul-04-2019, 11:35 PM
Last Post: scidam
  zip file variable prints <zipfile.ZipFile object at 0x7f83fd13bd90> ? Rsh 9 385 Jun-27-2019, 02:00 PM
Last Post: Rsh
  Save console output to text file (like a log) koticphreak 9 477 Jun-02-2019, 07:45 PM
Last Post: snippsat
  saving (in text or binary) an object under a defined class cai0824 3 316 May-12-2019, 08:55 AM
Last Post: snippsat

Forum Jump:

Users browsing this thread: 1 Guest(s)