[Tutor] general simply question

ken brockman krush1954 at yahoo.com
Thu Feb 9 09:07:44 CET 2012


Without sight of code it's only a guess but are you creating
the file with the 'wb' mode - ie. write binary? :-

myPickleFile = open("somefilename.dat", "wb")



oops. Not as in object orientated programming, just as in oops, i messed up. pasted wrong bit of code. Here is the relative bit.
def General_info():
file4 = open("Genfacts.p", "rb")
Ginfo = pickle.load(file4)
file4.close()
print('General Information: ')
GinfoKey = input('CatKey: ')
GinfoFact = input('Info: ')
Ginfo[GinfoKey] = GinfoFact  # add new key:fact
file4 = open("Genfacts.p", "wb")
pickle.dump(Ginfo, file4)
file4.close()
return(Ginfo)
Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120209/239b30b2/attachment.html>


More information about the Tutor mailing list