from urlparse import urlparse

url_str = "http://www.163.com/mail/index.htm"
url = urlparse(url_str)
print 'protocol:',url.scheme
print 'hostname:',url.hostname
print 'port:',url.port
print 'path:',url.path

i = len(url.path) - 1
while i > 0:
    if url.path[i] == '/':
        break
    i = i - 1
print 'filename:',url.path[i+1:len(url.path)]

 

posted on 2013-04-07 18:37  一个人的天空@  阅读(14855)  评论(0编辑  收藏  举报