如何在URL链接中将域名转换为IP,非常感谢!
草案代码:
import socket
ip_add = socket.gethostbyname("stopatnothing.com")
url = 'http://ip_add+:80/clients/'
预期结果:
http://204.232.151.56:80/clients/
答案 0 :(得分:3)
import socket
ip_add = socket.gethostbyname("stopatnothing.com")
url = 'http://%s:80/clients/' % ip_add