我很新的python。我試圖解析一個URL文件只留下域名。 我的日誌文件中的一些網址以http://開頭,有些以www.some開頭。 這是我的代碼的一部分剝去http://部分。我需要添加什麼來查找http和www。並刪除? line = re.findall(r'(https?://\S+)', line)
目前,當我運行的代碼只有http://被剝離。如果我將代碼更改爲以下內容: lin
我: from urlparse import urlparse
s = "http://google.com" + "\n" # this line is read from file, when I loop over file's lines
urlparse(s)
ParseResult(scheme='http', netloc='google.com\n', path='', p
有沒有一個標準功能來檢查IRI,來檢查URL顯然,我可以使用: parts = urlparse.urlsplit(url)
if not parts.scheme or not parts.netloc:
'''apparently not an url'''
我嘗試了上面的URL包含Unicode字符: import urlparse
url = "http://f