[Python] 用Python提取url链接中的域名与端口 →→→→→进入此内容的聊天室

来自 , 2019-02-14, 写在 Python, 查看 159 次.
URL http://www.code666.cn/view/7ec0dbee
  1. import urllib  
  2. proto, rest = urllib.splittype("http://www.sharejs.com/11/12.htm")  
  3. host, rest = urllib.splithost(rest)  
  4. print host  
  5. host, port = urllib.splitport(host)  
  6. if port is None:  
  7.    port = 80  
  8. print port  
  9. #//python/6086

回复 "用Python提取url链接中的域名与端口"

这儿你可以回复上面这条便签

captcha