How to right align IPaddress?

Discussion in 'Python' started by praba kar, Jun 17, 2005.

  1. praba kar

    praba kar Guest

    Dear all,

    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

    with regards,
    Prabahar



    _______________________________________________________
    Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for FREE! http://in.mail.yahoo.com
    praba kar, Jun 17, 2005
    #1
    1. Advertising

  2. praba kar

    Guest

    IPnumber.rjust(15)
    , Jun 17, 2005
    #2
    1. Advertising

  3. praba kar

    Guest

    Hi,
    the solution is a little more involved, if you want to "right justify"
    each of the
    four components of IP number:
    import sys
    try:
    .. sIPnumber=sys.argv[1]
    except:
    . sys.exit(-1)
    list_lPcomponents=sIPnumber.split('.')
    sRJ=''"
    for n in list_IPcomponents:
    .. sRJ+=n.rjust(3)+'.'
    print sRJ[:-1]
    Bye.
    , Jun 17, 2005
    #3
  4. >>>>> praba kar <> (pk) wrote:

    >pk> Dear all,
    >pk> Is it possible to right align
    >pk> the Ipaddress? Normally we can
    >pk> right align the list of numbers
    >pk> by %3u or %7u. How we can right
    >pk> align the Ipaddress?


    >pk> I expects below format output
    >pk> eg 203.199.200.0
    >pk> 203.33.20.0


    "%15s" % ip
    --
    Piet van Oostrum <>
    URL: http://www.cs.uu.nl/~piet [PGP]
    Private email:
    Piet van Oostrum, Jun 17, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kay
    Replies:
    2
    Views:
    7,146
  2. tshad

    text-align vs align

    tshad, Jun 23, 2005, in forum: HTML
    Replies:
    1
    Views:
    1,253
    David Dorward
    Jun 23, 2005
  3. Paul Lautman

    left align within centre align

    Paul Lautman, Mar 3, 2006, in forum: HTML
    Replies:
    3
    Views:
    570
    Paul Lautman
    Mar 3, 2006
  4. Bogdan
    Replies:
    1
    Views:
    782
    Bogdan
    Jun 16, 2009
  5. Oran
    Replies:
    2
    Views:
    532
Loading...

Share This Page