[Tutor] Formatted writing to a file

Alan G alan.gauld at freenet.co.uk
Fri May 27 23:58:37 CEST 2005


> 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
s = fmtString % data

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list