我们现在需要解析一个网址的协议、主机、端口与路径。
定义一个函数 parsed_url(),代码如下:
def parsed_url(url): # 默认协议是http protocol = 'http' if url[:7] == 'http://': u = url.split('://')[1] elif url[:8] == 'https://': protocol =
我们现在需要解析一个网址的协议、主机、端口与路径。
定义一个函数 parsed_url(),代码如下:
def parsed_url(url): # 默认协议是http protocol = 'http' if url[:7] == 'http://': u = url.split('://')[1] elif url[:8] == 'https://': protocol =