def local_ip():
    """Get the local network IP of this machine"""
    try:
        ip = socket.gethostbyname(socket.gethostname())
    except IOError:
        ip = socket.gethostbyname('localhost')
    if ip.startswith('127.'):
        ip = get_local_ip_by_interfaces()
        if ip is None:
            ip = get_local_ip_by_socket()
    return ip
def local_ip ( ) : try : ip = socket . gethostbyname ( socket . gethostname ( ) ) except IOError : ip = socket . gethostbyname ( 'localhost' ) if ip . startswith ( '127.' ) : ip = get_local_ip_by_interfaces ( ) if ip is None : ip = get_local_ip_by_socket ( ) return ip
Get the local network IP of this machine