1 Star 0 Fork 1.1K

流月/GreaterWMS

forked from GreaterWMS/GreaterWMS 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
start.py 692 Bytes
一键复制 编辑 原始数据 按行查看 历史
Singosgu 提交于 2021-10-08 06:57 +08:00 . V 2.0.26
import socket
import platform
def getip():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('www.baidu.com', 0))
ip = s.getsockname()[0]
except:
ip = "x.x.x.x"
finally:
s.close()
return ip
if __name__ == "__main__":
ip_address = "0.0.0.0"
sysstr = platform.system()
if sysstr == "Windows":
ip_address = socket.gethostbyname(socket.gethostname())
print("Windows @ " + ip_address)
elif sysstr == "Linux":
ip_address = getip()
print("Linux @ " + ip_address)
elif sysstr == "Darwin":
ip_address = socket.gethostbyname(socket.gethostname())
print("Mac @ " + ip_address)
else:
print("Other System @ some ip")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/tornadozz/GreaterWMS.git
git@gitee.com:tornadozz/GreaterWMS.git
tornadozz
GreaterWMS
GreaterWMS
master

搜索帮助