Parse a query given as a string argument. Arguments: qs: percent-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in percent-encoded queries should be treated as blank strings. A true value indicates that bla
(qs, keep_blank_values=False, strict_parsing=False,
encoding='utf-8', errors='replace', max_num_fields=None, separator='&')
| 857 | |
| 858 | |
| 859 | def parse_qs(qs, keep_blank_values=False, strict_parsing=False, |
| 860 | encoding='utf-8', errors='replace', max_num_fields=None, separator='&'): |
| 861 | """Parse a query given as a string argument. |
| 862 | |
| 863 | Arguments: |
| 864 | |
| 865 | qs: percent-encoded query string to be parsed |
| 866 | |
| 867 | keep_blank_values: flag indicating whether blank values in |
| 868 | percent-encoded queries should be treated as blank strings. |
| 869 | A true value indicates that blanks should be retained as |
| 870 | blank strings. The default false value indicates that |
| 871 | blank values are to be ignored and treated as if they were |
| 872 | not included. |
| 873 | |
| 874 | strict_parsing: flag indicating what to do with parsing errors. |
| 875 | If false (the default), errors are silently ignored. |
| 876 | If true, errors raise a ValueError exception. |
| 877 | |
| 878 | encoding and errors: specify how to decode percent-encoded sequences |
| 879 | into Unicode characters, as accepted by the bytes.decode() method. |
| 880 | |
| 881 | max_num_fields: int. If set, then throws a ValueError if there |
| 882 | are more than n fields read by parse_qsl(). |
| 883 | |
| 884 | separator: str. The symbol to use for separating the query arguments. |
| 885 | Defaults to &. |
| 886 | |
| 887 | Returns a dictionary. |
| 888 | """ |
| 889 | parsed_result = {} |
| 890 | pairs = parse_qsl(qs, keep_blank_values, strict_parsing, |
| 891 | encoding=encoding, errors=errors, |
| 892 | max_num_fields=max_num_fields, separator=separator, |
| 893 | _stacklevel=2) |
| 894 | for name, value in pairs: |
| 895 | if name in parsed_result: |
| 896 | parsed_result[name].append(value) |
| 897 | else: |
| 898 | parsed_result[name] = [value] |
| 899 | return parsed_result |
| 900 | |
| 901 | |
| 902 | def parse_qsl(qs, keep_blank_values=False, strict_parsing=False, |
searching dependent graphs…