Search notes:

Python standard library: ipaddress

import ipaddress

ip4 = '146.174.187.3'

addr = ipaddress.ip_address(ip4)

print(addr.version)                                                  # 4
print('.'.join([hex(x)[2:].upper().zfill(2) for x in addr.packed]))  # 92.AE.BB.03

See also

standard library

Index