import socket host_name = socket.gethostname() ip = socket.gethostbyname(host_name) print("本地IP地址是:" + ip)