示例代码:
from urlparse import urlparseo = urlparse('http://url.something.com/bla.html?querystring=stuff')url_without_query_string = o.scheme + "://" + o.netloc + o.path输出示例:
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> from urlparse import urlparse>>> o = urlparse('http://url.something.com/bla.html?querystring=stuff')>>> url_without_query_string = o.scheme + "://" + o.netloc + o.path>>> print url_without_query_stringhttp://url.something.com/bla.html>>> 


