URL unsplit and split
import urlparse print urlparse.urlunsplit(urlparse.urlsplit('http://www.java2s.com/path/a?'))