newbie question concerning formatted output

Thomas Liesner t.liesner at creativ-consulting.de
Tue Nov 29 18:40:08 CET 2005


Hello all,

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?

TIA,
./Tom



More information about the Python-list mailing list