Hi all,
I am trying convert IP addresses form Decimal format [Like] to HEX format [c0 a8 9d 80].
For Example the IP "" is equivalent to "c0 a8 9d 80" in HEX.
How to do that.??

Recommended Answers

All 2 Replies

One way.

>>> ip = ""
>>> ip = ip.split('.')
>>> ' '.join((hex(int(i))[2:] for i in ip))
'c0 a8 9d 80'
commented: It helped me alot... +3

Thanks a lot..buddy...!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.