1

need to convert IP address to unsigned long using Python. In C++ code I do this using

boost::asio::ip::address_v4::from_string("127.0.0.1").to_ulong()

Output: 2130706433

In Python so far I have been able to convert this to hex but not to ulong.

>>> socket.inet_aton('127.0.0.1')
'\x7f\x00\x00\x01'

Can you please help me with conversion of IP to ulong in Python?

user0042
  • 7,917
  • 3
  • 24
  • 39
shrishinde
  • 3,219
  • 1
  • 20
  • 31

0 Answers0