By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,932 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,932 IT Pros & Developers. It's quick & easy.

How to right align IPaddress?

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
IPnumber.rjust(15)

Jul 19 '05 #2

P: n/a
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.

Jul 19 '05 #3

P: n/a
>>>>> praba kar <pr*********@yahoo.co.in> (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 <pi**@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: pi**@vanoostrum.org
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.