Avatar ·

Need to find out my computer's IP address on the internet in Python

📁 ии, работа

In the documentation I found socket.gethostbyname(socket.gethostname()). But it gives me an error. gethostbyname doesn't work, I don't know why. Python version 3.2. Tell me why it might not work or another solution to the problem.

Avatar ·

for example:

method 1:

if len(set(sp)) == 1:    print("ALL SAME!!!")

method 2:

if [i for i in sp if i != sp[0]] == []:    print("ALL SAME!!!")

method 3 (probably the fastest):

if sp.count(sp[0]) == len(sp):    print("ALL SAME!!!")

Log in to leave an answer

Blogs