Python 区分IPv4与IPv6

 

区分IPv4与IPv6:

>>> import IPy
>>> ip_address = '172.19.10.178'
>>> print IPy.IP(ip_address).version()
4
>>> import IPy
>>> ip_address = '::1'
>>> print IPy.IP(ip_address).version()
6

  

posted @ 2020-09-03 11:06  爱敲代码的二百斤  阅读(1255)  评论(0编辑  收藏  举报