这是代码:
def isSrsInternal(srcip):
here i want to write code to check that srcip is local source to thet network or not
if srcip is local than it will return true
else return false
1任何人都可以给我写这个功能的想法
答案 0 :(得分:1)
您可以考虑使用ipaddress
模块:
>>> import ipaddress
>>> ip = ipaddress.IPv4Address('192.168.0.1')
>>> ip2 = ipaddress.IPv4Address('64.233.160.143') #Google's IP address
>>> ip.is_private
True
>>> ip2.is_private
False