“Gd”是什么意思?

2024-09-22 16:29:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我看到下面的G-d intended。我不明白这是什么意思有人知道吗?谢谢。你知道吗

Help on function parse_qsl in module urlparse:

parse_qsl(qs, keep_blank_values=0, strict_parsing=0)
    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 blanks should be retained as blank
        strings.  The default false value indicates that blank values
        are to be ignored and treated as if they were  not included.

    strict_parsing: flag indicating what to do with parsing errors. If
        false (the default), errors are silently ignored. If true,
        errors raise a ValueError exception.

    Returns a list, as G-d intended.

Tags: toinparseasbequeryvaluesparsing
1条回答
网友
1楼 · 发布于 2024-09-22 16:29:46

这个代码是committed in 1999*。从提交消息:

... [A] new function parse_qsl(), which is like

parse_qs() but returns a list of (name, value) pairs which is actually more correct. Use this where it makes sense.

显然,程序员认为返回名值对列表比返回字典更正确。因此,短语“如G-d所愿”是一种幽默的方式,表明返回列表比返回词典更好。请记住,1999年的Python社区比今天小得多,也更古怪:commit消息中的幽默(以及在社区和生态系统中常见的Monty Python引用)并不罕见。你知道吗

最初的程序员可能指的是如何处理具有重复键的查询字符串。可以说parse_qsl按顺序返回原始数据,而parse_qs则不返回。你知道吗

>>> pairs = [('a', 1), ('a', 2), ('b', 3)]
>>> qs = parse.urlencode(pairs)
>>> qs
'a=1&a=2&b=3'
>>> parse.parse_qs(qs)
{'a': ['1', '2'], 'b': ['3']}
>>> parse.parse_qsl(qs)
[('a', '1'), ('a', '2'), ('b', '3')]

*在最初的承诺中,神圣的参考是不模糊的。混淆是作为this commit的一部分引入的,没有具体的解释。你知道吗

相关问题 更多 >