Registry / http-networking / query-string

query-string

JSON →
library2020.12.3pypypi✓ verified 87d ago

A lightweight Python library for parsing and manipulating URL query strings. The current version is 2020.12.3, released in December 2020. Development appears inactive; no new releases since then.

pip install query-string==2020.12.3
INSTALL
IMPORT
SIG · QUERY-STRING
Q
query-string
http-networkingpythonv2020.12.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
from query_string import parse
import query_string
Direct import of module is possible but parse() is the main function
parse
from query_string import parse
from query_string import query_string
No class named query_string

Parse a URL query string into a dictionary.

from query_string import parse url = "http://example.com?foo=1&bar=2" params = parse(url) print(params) # {'foo': '1', 'bar': '2'}
Debug
Known issues
gotchaThe parse() function expects a full URL string, not just the query part. If you pass only 'key=value', it may fail or return unexpected results.
fix
Always pass a full URL including scheme and host, or prefix with 'http://example.com/?'.
affects: all
deprecatedThis library is effectively deprecated. No releases since 2020. The author recommends using urllib.parse (stdlib) or the requests library instead.
fix
Use 'from urllib.parse import urlparse, parse_qs' or 'import requests'.
affects: >=2017.0.0
gotchaThe library returns values as strings. It does not perform type conversion. Query parameters like 'num=42' will be string '42', not integer 42.
fix
Convert values manually after parsing.
affects: all
breakingIn version 2020.12.3, the parse function behavior changed regarding duplicate keys. Previously, it returned the last value; now it returns a list of values for duplicate keys.
fix
If you expect a single value, use dict comprehension to take the first or last element from the list.
affects: >=2020.12.3
Errors
Common errors & fixes
AttributeError: module 'query_string' has no attribute 'parse'
Importing the module itself instead of the function.
fix
Use 'from query_string import parse'.
ValueError: Invalid URL
Passing only a query string (e.g., 'foo=1') without a full URL.
fix
Ensure you pass a full URL like 'http://example.com?foo=1'.
Upgrade
Version history
2020.12.3latest on PyPI · released Dec 3, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
query-string — pip install query-string · libregistry