在python中獲取mac和ip地址
python 獲得本機MAC地址:import uuid
def get_mac_address():
mac=uuid.UUID(int=uuid.getnode()).hex[-12:]
return ":".join([mac[e:e+2] for e in range(0,11,2)])
python獲取IP的方法:使用socket
import socket
myname=socket.getfqdn(socket.gethostname( ))
myaddr=socket.gethostbyname(myname)
print(myname)
print(myaddr)
posted on 2017-05-15 23:26 鴻雁 閱讀(252) 評論(0) 編輯 收藏 所屬分類: IT技術相關