ipv4v6:一个用于获取公网IP的库(超轻量级)

作者的新作品ipv4v6已上传pypi,用于获取公网IP地址,可通过以下代码安装:

pip install ipv4v6

Thank you for supporting!

  • Function get_ip() is used to get your ipv4 address including host and port.

    from ipv4v6 import get_ip
    print(get_ip()) #It'll print something like 117.143.170.80:2653
    
  • Function get_ipv4() is used to get your ipv4 address including only host.

    from ipv4v6 import get_ipv4
    print(get_ipv4()) #It'll print something like 117.143.170.80
    

    (Tips : If you just want to get ipv4 address, get_ip() is a better choice because it’s faster than get_ipv4)

  • Function get_ipv6() is used to get your ipv6 address including only host.

    from ipv4v6 import get_ipv6
    print(get_ipv6())
    #It'll print something like 2409:8a1e:6e81:4280:6456:3051:4f3f:1965
    
  • Function ip_tuple() returns a tuple which contains the host and the port of your ipv4 address.
    (Tips : It can be given to socket.connect() as parameter)

    from socket import *
    from ipv4v6 import ip_tuple
    sock=socket(AF_INET,SOCK_STREAM)
    sock.connect(ip_tuple())
    
  • Function get_ipv4_location() and get_ipv6_location returns the location of your ip address.

    from ipv4v6 import get_ipv4_location
    from ipv4v6 import get_ipv6_location
    print(get_ipv4_location()) #It'll print the location
    print(get_ipv6_location()) #It'll print the location
    
  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值