[Tutor] Pickle Module

Deirdre Hackett Deirdre Hackett" <deirdrehac@lycos.co.uk
Wed Jan 29 11:17:08 2003


This is a multi-part message in MIME format.

------=_NextPart_000_00CE_01C2C7B1.C22D9060
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I want to use pickle module

import pickle
   =20
f =3D open('/Python22/testing3.txt', 'w')

data =3D [23,34,34]

pickle.dump(data,f)

I want to write data to the file testing3.txt.
=20
I tried f.write(data) but you are only allowed to write strings to the =
file and it said in the documentation that pickle was the way to do it.

Not sure where to go here.

Thanks=20
Dee

------=_NextPart_000_00CE_01C2C7B1.C22D9060
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I want to use pickle =
module</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><EM><STRONG><FONT face=3DArial size=3D2>import=20
pickle</FONT></STRONG></EM></DIV>
<DIV><EM><STRONG><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
</FONT></STRONG></EM></DIV>
<DIV><EM><STRONG><FONT face=3DArial size=3D2>f =3D =
open('/Python22/testing3.txt',=20
'w')</FONT></STRONG></EM></DIV>
<DIV>&nbsp;</DIV>
<DIV><EM><STRONG><FONT face=3DArial size=3D2>data =3D=20
[23,34,34]</FONT></STRONG></EM></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2><STRONG><EM>pickle.dump(data,f)</EM></STRONG></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I want to write <EM><STRONG>data =
</STRONG></EM>to=20
the file testing3.txt.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I tried =
<STRONG><EM>f.write(data)</EM></STRONG> but=20
you are only allowed to write strings to the file and it said in the=20
documentation that pickle was the way to do it.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Not sure where to go here.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Dee</FONT></DIV></BODY></HTML>

------=_NextPart_000_00CE_01C2C7B1.C22D9060--