dengyg200891
import socket

print socket.gethostname()#主机名
hostname=socket.gethostname()
    
#传递主机名
print socket.gethostbyname(hostname)#192.168.1.102
    
#参数传递网址
print socket.gethostbyname(\'www.163.com\')#58.20.197.62

#返回一个三元素列表,传递的参数为IP地址
print socket.gethostbyaddr(\'202.165.102.205\')#(\'UNKNOWN-202-165-102-X.yahoo.com\', [], [\'202.165.102.205\'])

#参数为一个服务名和一个协议名
#返回端口号
print socket.getservbyname(\'http\',\'tcp\')#80

 

分类:

技术点:

相关文章:

  • 2021-12-22
  • 2022-01-11
  • 2022-12-23
  • 2021-09-05
  • 2022-01-02
  • 2021-12-31
  • 2022-12-23
  • 2021-12-03
猜你喜欢
  • 2021-12-03
  • 2021-09-16
  • 2022-01-14
  • 2021-11-23
  • 2021-12-18
  • 2021-09-16
相关资源
相似解决方案