[Tutor] Formatted writing to a file

Bob Gailer bgailer at sbcglobal.net
Sat May 28 05:12:36 CEST 2005


At 02:58 PM 5/27/2005, Alan G wrote:
> > 1. how can I format outfile so i can write multiple lines
> > and then apend multiple lines later before closing the file?
>
>I think you mean add a new column to the existing lines?
>
>try something like
>
>line = line + '%25s' % newdata
>
> > 2. how can I make data formatting string '%25s' intiger (in this
>case 25) a variable?
>
>
>Just create the string outsoide the formatting line:
>
>fmtString = '%%ds' % width

I think it should be '%%%ds' % width

>s = fmtString % data
>
>HTH,
>
>Alan G
>Author of the Learn to Program web tutor
>http://www.freenetpages.co.uk/hp/alan.gauld
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor

Bob Gailer
mailto:bgailer at alum.rpi.edu
510 558 3275 home
720 938 2625 cell  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050527/42c87018/attachment.html


More information about the Tutor mailing list