Answers for "ip python"

1

get ip python

import socket    
host = socket.getfqdn()    
addr = socket.gethostbyname(host)
print(f"Your ip is {addr}")
# On Linux, it may give you the localhost address
Posted by: Guest on November-18-2020
0

python get all ips in a range

def ips(start, end):
    import socket, struct
    start = struct.unpack('>I', socket.inet_aton(start))[0]
    end = struct.unpack('>I', socket.inet_aton(end))[0]
    return [socket.inet_ntoa(struct.pack('>I', i)) for i in range(start, end)]
Posted by: Guest on April-03-2020

Python Answers by Framework

Browse Popular Code Answers by Language