newbie question concerning formatted output
dwelch
donald.welch at hp.com
Tue Nov 29 15:43:14 EST 2005
Thomas Liesner wrote:
> 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
Might be more than you need, but I've employed "TextFormatter"
(http://www.faqts.com/knowledge_base/view.phtml/aid/4517) to good effect.
-Don
More information about the Python-list
mailing list