How to right align IPaddress?
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to right align IPaddress?
IPnumber.rjust(15) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to right align IPaddress?
On Fri, 17 Jun 2005 09:46:52 +0100 (BST) praba kar [EMAIL PROTECTED] 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] -- http://mail.python.org/mailman/listinfo/python-list
Re: How to right align IPaddress?
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to right align IPaddress?
praba kar [EMAIL PROTECTED] (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 [EMAIL PROTECTED] URL: http://www.cs.uu.nl/~piet [PGP] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list