Conversion from IP string to integer, and backward in Python

后端 未结 11 867
囚心锁ツ
囚心锁ツ 2020-12-07 22:34

i have a little problem with my script, where i need to convert ip in form \'xxx.xxx.xxx.xxx\' to integer representation and go back from this form.

def ipto         


        
11条回答
  •  心在旅途
    2020-12-07 23:01

    Python 3 has ipaddress module which features very simple conversion:

    int(ipaddress.IPv4Address("192.168.0.1"))
    str(ipaddress.IPv4Address(3232235521))
    

提交回复
热议问题