Thomas Liesner wrote: > i am having some hard time to format the output of my small script. I am > opening a file which containes just a very long string of hexdata > seperated by spaces. Using split() i can split this string into single > words and print them on stdout. So far so good. But i want to print always > three of them in a single line and after that a linebreak. > > So instead of: > > 3905 > 3009 > 0000 > 4508 > f504 > 0000 > 3707 > 5a07 > 0000 > etc... > > i'd like to have: > > 3905 3009 0000 > 4508 f504 0000 > 3707 5a07 0000 > etc... > > This is the codesnippet i am using: > > #!/usr/bin/python > > import string > inp = open("xyplan.nobreaks","r") > data = inp.read() > for words in data.split(): > print words > inp.close() > > Any hints?
how about inp = open("xyplan.nobreaks","r") data = inp.read() import textwrap for line in textwrap.wrap(data, 15): print line </F> -- http://mail.python.org/mailman/listinfo/python-list