[Tutor] print issue

Alan Gauld alan.gauld at btinternet.com
Wed Oct 2 18:51:29 EDT 2019


On 02/10/2019 23:38, Alan Gauld via Tutor wrote:

Almost...

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

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