Pickle Problem

odeits odeits at gmail.com
Tue Mar 3 07:21:36 EST 2009


On Mar 3, 4:16 am, Fab86 <fabien.h... at gmail.com> wrote:
> Thanks, this seems like a simpler way to do it.
>
> I plan on recording 200 values to this file from the outcome of 200
> Yahoo searches. Is there any type of loop I can make to do this or do
> I have to have a line like "print >> f, res1.total_results_available"
> 200 times?
>
> Regards,
>
> Fabien
>
> On Mar 3, 12:00 pm, "andrew cooke" <and... at acooke.org> wrote:
>
> > maybe the following are simpler as they use print
>
> > if you are using python 2.6 or python 3:
>
> > >>> from __future__ import print_function
> > >>> f = open('myfile.txt', 'w')
> > >>> print(123, file=f)
> > >>> print(456, file=f)
> > >>> f.close()
>
> > alternatively, in python 2.5 or 2.6:
>
> > >>> f = open('myfile.txt', 'w')
> > >>> print >> f, 123
> > >>> print >> f, 456
> > >>> f.close()
>
> > andrew
>
>

How are you getting res1, res2? in most cases you could just use a for
loop

for res in results:
   print >> f, res.total_results_available



More information about the Python-list mailing list