本文实例讲述了python获取本机mac地址和ip地址的方法。分享给大家供大家参考。具体如下:
import sys, socket
def getipaddrs(hostname):
result = socket.getaddrinfo(hostname,None,0,socket.SOCK_STREAM)
return [x[4][0] for x in result]
# the name of the local machine
hostname = socket.gethostname()
try:
print IP addresses:, , .join(g