Still Question about print format?
Mindy
csshi99 at yahoo.com
Thu Nov 7 18:25:25 EST 2002
> If what you really wanted was to create a classic
> "report" (static
> formatted output for consumption by humans), you
> shouldn't be using tabs
> at all. Look at using the string methods "center",
> "ljust" and "rjust",
> which will give you your string values with
> space-padding to be exactly
> a given length.
That's really what I want to do but I didn't explain
it clearly. Thanks for your clarifying. I tried to use
ljust as you said and modified my codes as the
following. But I still couldn't get the aligned
result. Did I mess up in any place? Thanks so much.
form = """
%(index)d
%(symbol)s
%(binding_file)s
%(to_file)s\n
"""
string.ljust(symbol,50)
string.ljust(binding_file[0],50)
tring.ljust(to_file[0],50)
print >>fp1, form%{'index':i,
'symbol':symbol,
'binding_file':binding_file[0],
'to_file':to_file[0],
}
The results I got:
4
`_XmInheritClass'
netscape
netscape
They are not what I want as aligning 4 columns in a
row such as:
4 `_XmInheritClass' netscape netscape
=====
Cheers
-Mindy
__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2
More information about the Python-list
mailing list