python 查看服务器主机 IP 地址
import socket
hostname = socket.gethostname() ## 获取主机名
ip_address = socket.gethostbyname(hostname) # 通过主机名获取 IP 地址
print(“服务器主机 IP 地址为:”, ip_address)
import socket
hostname = socket.gethostname() ## 获取主机名
ip_address = socket.gethostbyname(hostname) # 通过主机名获取 IP 地址
print(“服务器主机 IP 地址为:”, ip_address)