Python URL format parsing

From , 4 Years ago, written in Python, viewed 49 times.
URL https://pastebin.vip/view/4dbf29d9
  1. from urlparse import urlparse
  2.  
  3. url_str = "http://www.163.com/mail/index.htm"
  4. url = urlparse(url_str)
  5. print 'protocol:',url.scheme
  6. print 'hostname:',url.hostname
  7. print 'port:',url.port
  8. print 'path:',url.path
  9. print 'query:'url.query #查询参数,格式a=1
  10.  
  11. i = len(url.path) - 1
  12. while i > 0:
  13.     if url.path[i] == '/':
  14.         break
  15.     i = i - 1
  16. print 'filename:',url.path[i+1:len(url.path)]
  17. #//python/7153

Reply to "Python URL format parsing"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website