How to right align IPaddress?

P

praba kar

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
 
Q

qwweeeit

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.
 
P

Piet van Oostrum

praba kar said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top