This article mainly introduces Python to obtain the native MAC address and the IP address method, involves Python to obtain the system related information the skill, needs the friend to be possible to refer to under
The example in this article describes how Python obtains native MAC addresses and IP addresses. Share to everyone for your reference. Specifically as follows:
|1 2 3 4 5 6 7 8 9 10||Import sys, socket def GETIPADDRS (hostname): result = Socket.getaddrinfo (hostname,none,0,socket. SOCK_STREAM) return [x for x to result] # The name of the ' Local machine hostname = Socket.gethostname () try:print " IP addresses: ",", ". Join (Getipaddrs (hostname)) except Socket.gaierror, e:print" couldn ' t get IP addresses: ", E|
I hope this article will help you with your Python programming.