Django Book 翻译
菜单>:
TOC
返回
原文:
.. table:: H-4. Extra (Nondictionary) QueryDict Methods +---------------------+-------------------------------------------------------+ |Method |Description | +=====================+=======================================================+ |``copy()`` |Returns a copy of the object, using ``copy.deepcopy()``| | |from the Python standard library. The copy will be | | |mutable that is, you can change its values. | +---------------------+-------------------------------------------------------+ |``getlist(key)`` |Returns the data with the requested key, as a Python | | |list. Returns an empty list if the key doesnt exist. | | |Its guaranteed to return a list of some sort. | +---------------------+-------------------------------------------------------+ |``setlist(key, |Sets the given key to ``list_`` (unlike | |list_)`` |``__setitem__()`` ). | +---------------------+-------------------------------------------------------+ |``appendlist(key, |Appends an item to the internal list associated with | |item)`` |``key`` . | +---------------------+-------------------------------------------------------+ |``setlistdefault(key,|Just like ``setdefault`` , except it takes a list of | |l)`` |values instead of a single value. | +---------------------+-------------------------------------------------------+ |``lists()`` |Like ``items()`` , except it includes all values, as a | | |list, for each member of the dictionary. For example: | | | | | |:: | | | | | | | | | >>> q = QueryDict('a=1&a=2&a=3') | | | >>> q.lists() | | | [('a', ['1', '2', '3'])] | | | | | |.. | | | | | | | +---------------------+-------------------------------------------------------+ |``urlencode()`` |Returns a string of the data in query-string format | | |(e.g., ``"a=2&b=3&b=5"`` ). | +---------------------+-------------------------------------------------------+
翻译:
.. table:: 表 H-4. 附加的 (非字典的) QueryDict 方法 +---------------------+-------------------------------------------------------+ |方法 |描述 | +=====================+=======================================================+ |``copy()`` |返回一个对象的副本,使用的是Python标准库中的 | | |``copy.deepcopy()`` 。 该副本是可变的, | | |也就是说,你能改变它的值。 | +---------------------+-------------------------------------------------------+ |``getlist(key)`` |以Python列表的形式返回所请求键的数据。 | | |若键不存在则返回空列表。 | | |它保证了一定会返回某种形式的list。 | +---------------------+-------------------------------------------------------+ |``setlist(key, |将所给键的键值设为 ``list_`` | |list_)`` |(与 ``__setitem__()`` 不同)。 | +---------------------+-------------------------------------------------------+ |``appendlist(key, |在 ``key`` 相关的list上增加 ``item`` 。 | |item)`` | | +---------------------+-------------------------------------------------------+ |``setlistdefault(key,|和 ``setdefault`` 一样, 不同的是它的第二个参数是 | |l)`` |一个列表,而不是一个值。 | +---------------------+-------------------------------------------------------+ |``lists()`` |和 ``items()`` 一样, 不同的是它以一个列表的形式 | | |返回字典每一个成员的所有值。 例如: | | | | | |:: | | | | | | | | | >>> q = QueryDict('a=1&a=2&a=3') | | | >>> q.lists() | | | [('a', ['1', '2', '3'])] | | | | | |.. | | | | | | | +---------------------+-------------------------------------------------------+ |``urlencode()`` |返回一个请求字符串格式的数据字符串 | | |(如, ``"a=2&b=3&b=5"`` )。 | +---------------------+-------------------------------------------------------+
备注:
译者: