print shell output in a file

Stephan Wassipaul wassipaul at gmx.at
Fri Jun 30 16:42:55 CEST 2006


f = file('output.txt','w')
print >>f, '%-30s | %-12d | %-12d |%-12d ' % (typename,
                                               size / count,
                                               count,
                                               size)
f.close()
> hello,
> 
> one more question i will have!
> 
> now i have written a little programm, which delivers me an output on the
> shell!
> 
> 
> here is the print command, which delivers me the following output (see
> below) on the shell:
> 
> 
>  print '%-30s | %-12d | %-12d |%-12d ' % (typename,
>                                                   size / count,
>                                                   count,
>                                                   size)
> 
> 
> 
> --------------NAME-------------|Groesse(Byte)-|----Anzahl----|-Gesamtgroesse
> (Byte)-|
> ----------------------------------------------------------------------------
> ----------
> ADD_REAL_N6                    | 4            | 1            |4
> AND_BOOL_N10                   | 4            | 1            |4
> AND_BOOL_N12                   | 4            | 1            |4
> 
> 
> 
> Is there a way to put this output in an file?!?! i searched about 2h for
> this, but i couldn`t find an answer!
> 
> thnks, juergen
> 



More information about the Python-list mailing list