convert ints in a range to strings

Duncan Smith buzzard at urubu.freeserve.co.uk
Thu Sep 18 09:16:40 EDT 2003


"hokiegal99" <hokiegal99 at hotmail.com> wrote in message
news:3F6900D2.7080806 at hotmail.com...
> Thanks Heather... this did it:
>
> outputFile = file('ips.txt', 'w')
> r = range(256)
> for r in range(256):
>     f = '192.168.1.%s\n' % r #Change this line to macth your network.
>     outputFile.write(f)
> outputFile.close()
>

[snip]

The second line of this code does nothing useful.  My feeling is that as r
is an integer you should really use %d, rather than %s.

Duncan






More information about the Python-list mailing list