[Tutor] print issue

Alan Gauld alan.gauld at btinternet.com
Wed Oct 2 18:38:33 EDT 2019


On 02/10/2019 18:49, Alan Gauld via Tutor wrote:

> Not sure why the formatting got messed up, I'll try again!

And 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


Hopefully this comes through OK...


-- 
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