Is this a good way of getting the local ip? /u/Celestial-being117 Python Education

def getLanIp(): interfaces = psutil.net_if_addrs() stats = psutil.net_if_stats() for interface_name, snics in interfaces.items(): if interface_name in stats and stats[interface_name].isup: print(interface_name) for snic in snics: if snic.family == socket.AF_INET: return snic.address

submitted by /u/Celestial-being117
[link] [comments]

​r/learnpython def getLanIp(): interfaces = psutil.net_if_addrs() stats = psutil.net_if_stats() for interface_name, snics in interfaces.items(): if interface_name in stats and stats[interface_name].isup: print(interface_name) for snic in snics: if snic.family == socket.AF_INET: return snic.address submitted by /u/Celestial-being117 [link] [comments] 

def getLanIp(): interfaces = psutil.net_if_addrs() stats = psutil.net_if_stats() for interface_name, snics in interfaces.items(): if interface_name in stats and stats[interface_name].isup: print(interface_name) for snic in snics: if snic.family == socket.AF_INET: return snic.address

submitted by /u/Celestial-being117
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *