Python parse http query string Urlparse.parse_qs__python

Source: Internet
Author: User

Parse_qs has several implementations

Urlparse.parse_qs Return Dictionary
URLPARSE.PARSE_QSL return List
This module is renamed Urllib.parse in Python 3.0.

Urllib.parse.parse_qs Return Dictionary
URLLIB.PARSE.PARSE_QSL return List

The two functions in the CGI have been discarded and remain in the module for backward compatibility only, recommended for use with Urlparse.parse_qs and URLPARSE.PARSE_QSL
Cgi.parse_qs
Cgi.parse_qsl

Import urlparse
qsdata = "Test=test&test2=test2&test2=test3"
qs = Dict ((k, v if Len (v) >1 else v[0]) 
 for K, V in Urlparse.parse_qs (Qsdata). Iteritems ())
print QS
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.