用Python提取url链接中的域名与端口:
- import urllib
- proto, rest = urllib.splittype("http://www.baidu.com/11/12.htm")
- host, rest = urllib.splithost(rest)
- print host
- host, port = urllib.splitport(host)
- if port is None:
- port = 80
- print port
|
背景:
阅读新闻
相关资讯
python
|
最新资讯
|