def getLocalIpList():
"""获取本机ip列表"""
if sys.platform == "win32":
return [socket.gethostbyname(socket.gethostname())]
content = os.popen("ifconfig").read()
return [re.split(r"\s+", line.strip()) for line in content.splitlines() if line.strip().startswith("inet")]
Python 获取电脑本机ip列表
于 2023-10-23 20:42:26 首次发布