[Tutor] Help with saving data
Andrew Wilkins
toodles@yifan.net
Mon, 30 Apr 2001 17:32:14 +0800
Using pickle (or cPickle for an improvement in speed) should be sufficient.
example:
import cPickle
my_dict={'example':'123'} #dictionary for saving
file_path='c:\\file.tmp'
file=open(file_path,'w') #open the file for reading
cPickle.dump(my_dict,file) #save to file
file.close()
file=open(file_path) #open for reading
cPickle.dump(my_dict,file) #read from file
file.close()
The pickle module also supports other types, as well as user defined
classes. I don't know a lot about the module, I've only just started using
it...I'm about part way through making a MUD system...I'll put it up on
Useless once I'm done...sound good Rob? =)
> PS. Andrew, your email helped, thx!
No worries, that's what I'm here for...apart from lurking of course heh heh
Andrew
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>