UrlEncode and UrlDecode in Python

Source: Internet
Author: User
Tags urlencode

Python converts a string into a urlencode, or a URL-encoded string decode: Method1: The quote method in Urlencode:urllib>>>  fromUrllibImportQuote>>>Quote': ')'%3a '>>>Quote' http://www.baidu.com ')' http%3a//www.baidu.com 'The Unquote method in Urldecode:urllib>>>  fromUrllibImportUnquote>>>Unquote (' http%3a//www.baidu.com ')' http://www.baidu.com 'Method two Urllib.urlencode () Unfortunately, this function can only receive key-The value pair format data. That is only for dict and does not currently provide the UrlDecode method>>> ImportUrllib>>>Params=Urllib.urlencode ({' spam ':1,' eggs ':2,' Bacon ':0})>>>Params=Urllib.urlencode ({' spam ':1,' eggs ':2,' Bacon ':0})>>>Params# # #自动转化成下面url的参数形式' Eggs=2&bacon=0&spam=1 '>>>F=Urllib.urlopen ("Http://www.musi-cal.com/cgi-bin/query?"%s" %Params>>> PrintF.read ()

UrlEncode and UrlDecode in Python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.