1

Is there a parse_str (used in php) alternative for python?

http://php.net/manual/en/function.parse-str.php
parse_str — Parses the string into variables

2 Answers 2

2

urlparse.parse_qs: http://docs.python.org/library/urlparse.html#urlparse.parse_qs

If you are using a Python older than 2.6, the previous location of this function was in the cgi module: http://docs.python.org/library/cgi.html#cgi.parse_qs

Sign up to request clarification or add additional context in comments.

4 Comments

The problem is ... >>> import urlparse >>> dir(urlparse) ['BaseResult', 'MAX_CACHE_SIZE', 'ParseResult', 'SplitResult', 'all', 'builtins', 'doc', 'file', 'name', '_parse_cache', '_splitnetloc', '_splitparams', 'clear_cache', 'non_hierarchical', 'scheme_chars', 'test', 'test_input', 'urldefrag', 'urljoin', 'urlparse', 'urlsplit', 'urlunparse', 'urlunsplit', 'uses_fragment', 'uses_netloc', 'uses_params', 'uses_query', 'uses_relative']
@vkris: So what? That's everything that's in the module urlparse, but Adam already told you which one you need.
@vkris: What's you Python version? Docs say parse_qs was added in 2.6 (which is quite old).
Have you tried it instead of just checking module definition crap?
1

If you are using Python<2.6

parse_qs is in the cgi module

It's still there in 2.7 for backward compatibility

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.