python increment ipaddress

后端 未结 8 2170
情话喂你
情话喂你 2020-12-31 09:24

I would like to increment an ip address by a fixed value.

Precisely this is what I am trying to achieve, I have an ip address say, 192.168.0.3 and I wan

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-31 10:16

    EDIT: This is buggy and shouldn't be used as is.

    I would use ipaddr for this

    >>> import ipaddr
    >>> a = ipaddr.IPAddress('192.168.0.3')
    >>> a
    IPv4Address('192.168.0.3')
    >>> a + 1
    IPv4Address('192.168.0.4')
    

提交回复
热议问题