import sys, socketdef getipaddrs(hostname): result = socket.getaddrinfo(hostname,none,0,socket.sock_stream) return [x[4][0] for x in result]# the name of the local machinehostname = socket.gethostname()try: print ip addresses:, , .join(getipaddrs(hostname))except socket.gaierror, e: print couldn't not get ip addresses:, e
希望本文所述对大家的python程序设计有所帮助。
