[Tutor] print issue
Alan Gauld
alan.gauld at btinternet.com
Wed Oct 2 13:49:10 EDT 2019
On 02/10/2019 17:38, Alan Gauld via Tutor wrote:
>
> We have already given you several suggestions, I will incorporate them
> below: I will assume that for some reason you need to use Python v2...
Not sure why the formatting got messed up, I'll try again!
with open('output.txt', 'r') as reader: counter = 100 fmtString =
"%11s-[%d, 'tcp', 'allow', %s, null, null, %d, %d]\n" with open
('samplefile.txt', 'w') as p: for line in reader: address = line.strip()
p.write(fmtString % (" ", counter, address, 500,500)) counter +=100
p.write(fmtString % (" ", counter, address, 800,800)) counter +=100
I cheated slightly and moved the second 'open()' line up a bit too... :-)
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list