How to convert decimal IP to HEX IP
Hi all,
I am trying convert IP addresses form Decimal format [Like 192.168.12.13] to HEX format [c0 a8 9d 80].
For Example the IP "192.168.157.128" is equivalent to "c0 a8 9d 80" in HEX.
How to do that.??
debasishgang7
Junior Poster in Training
91 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
One way.
>>> ip = "192.168.157.128"
>>> ip = ip.split('.')
>>> ' '.join((hex(int(i))[2:] for i in ip))
'c0 a8 9d 80'
>>>
snippsat
Practically a Posting Shark
808 posts since Aug 2008
Reputation Points: 353
Solved Threads: 294
debasishgang7
Junior Poster in Training
91 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0