“Python erhalten IP -Adresse” Code-Antworten

Holen Sie sich externe IP -Python

# This example requires the requests library be installed.  You can learn more
# about the Requests library here: http://docs.python-requests.org/en/latest/

from requests import get

ip = get('https://api.ipify.org').text
print 'My public IP address is:', ip
Joeyeyey

Holen Sie sich die IP -Adresse Python

import socket    
hostname = socket.gethostname()    
IPAddr = socket.gethostbyname(hostname)    
print("Your Computer Name is:" + hostname)    
print("Your Computer IP Address is:" + IPAddr) 
#How to get the IP address of a client using socket
Clumsy Caterpillar

So erhalten Sie Benutzer IP in Python

import socket    
host_name = socket.gethostname()    
IPAddress = socket.gethostbyname(host_name)    
print("Your Computer Name is:" + host_name)    
print("Your Computer IP Address is:" + IPAddress) 
#How to get the IP address of a client using socket module
Stupid Sheep

Python Holen Sie sich Lan IP

import socket
def get_ip():
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        # doesn't even have to be reachable
        s.connect(('10.255.255.255', 1))
        IP = s.getsockname()[0]
    except Exception:
        IP = '127.0.0.1'
    finally:
        s.close()
    return IP
The Nic

Holen Sie sich die IP -Adresse Python

 socket.gethostbyname(socket.gethostname())
Thankful Toucan

Python erhalten IP -Adresse

import requests

# Prints public IPv4 address:
print(requests.get('https://utilities.tk/network/info').json()['ip'])

# Prints more info like location, hostname etc
print(requests.get('https://utilities.tk/network/info').json())
ProxyBlade

Ähnliche Antworten wie “Python erhalten IP -Adresse”

Fragen ähnlich wie “Python erhalten IP -Adresse”

Weitere verwandte Antworten zu “Python erhalten IP -Adresse” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen