你应该能够做到urlparse(docs:python2,python3):
from urllib.parse import urlparse# from urlparse import urlparse # Python 2parsed_uri = urlparse('http://stackoverflow.com/questions/1234567/blah-blah-blah-blah' )result = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_uri)print(result)# gives'http://stackoverflow.com/'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)