How to right align IPaddress?

Denis S. Otkidach ods at strana.ru
Fri Jun 17 05:10:21 EDT 2005


On Fri, 17 Jun 2005 09:46:52 +0100 (BST)
praba kar <prabapython at yahoo.co.in> wrote:

>      Is it possible to right align
> the Ipaddress?  Normally we can
> right align the  list of numbers
> by %3u or %7u.  How we can right
> align the Ipaddress? 
> 
> I expects below format output
> eg 203.199.200.0
>      203.33.20.0

>>> for ip in ('203.199.200.0', '203.33.20.0'):
...     print '%15s' % ip
... 
  203.199.200.0
    203.33.20.0
>>> for ip in ('203.199.200.0', '203.33.20.0'):
...     print ip.rjust(15)
... 
  203.199.200.0
    203.33.20.0

-- 
Denis S. Otkidach
http://www.python.ru/      [ru]



More information about the Python-list mailing list