我有:s = "http://google.com" + "\n" # this line is read from file, whenI loop over file's lines ParseResult(scheme='http', netloc='google.com\n', path='', params
Python 2.7。我试图遍历unicode url的列表,分割和重建它们以删除部分url。for line in list_of_links: new_list.append(line.scheme + '://' + line.netloc + line.path)
返回AttributeError: 'unicode' object has no attribute 'scheme
否则,不要管url,所以我认为urlparse是正确的方式。但是每当没有方案并且我使用get url时,我在方案和域之间得到的是/而不是'//‘。>>> t = urlparse.urlparse('www.example.com', 'http')'http:///www.example.com' # three
我试图找出为什么我看到一个错误ModuleNotFoundError: No module named 'urlparse',但我从来没有在我的代码中调用urlparse。当我尝试用pip安装urlparse时,我发现这个模块并不存在。当我尝试用pip安装urllib.parse时,我在urllib.parse上看到了同样的消息。