~ubuntu-branches/ubuntu/precise/python3.2/precise

« back to all changes in this revision

Viewing changes to Doc/library/urllib.parse.rst

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2011-02-14 16:12:14 UTC
  • mfrom: (10.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20110214161214-f5vwa226kebccmt9
Tags: 3.2~rc3-1
Python 3.2 release candidate 3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
   Use the :func:`urllib.parse.urlencode` function to convert such
141
141
   dictionaries into query strings.
142
142
 
 
143
 
143
144
   .. versionchanged:: 3.2
144
145
      Add *encoding* and *errors* parameters.
145
146
 
279
280
   object.
280
281
 
281
282
   .. versionchanged:: 3.2
282
 
      Result is a structured object rather than a simple 2-tuple
 
283
      Result is a structured object rather than a simple 2-tuple.
283
284
 
 
285
.. _parsing-ascii-encoded-bytes:
284
286
 
285
287
Parsing ASCII Encoded Bytes
286
288
---------------------------
505
507
.. function:: urlencode(query, doseq=False, safe='', encoding=None, errors=None)
506
508
 
507
509
   Convert a mapping object or a sequence of two-element tuples, which may
508
 
   either be a :class:`str` or a :class:`bytes`,  to a "percent-encoded" string,
509
 
   suitable to pass to :func:`urlopen` above as the optional *data* argument.
510
 
   This is useful to pass a dictionary of form fields to a ``POST`` request.
 
510
   either be a :class:`str` or a :class:`bytes`,  to a "percent-encoded"
 
511
   string.  The resultant string must be converted to bytes using the
 
512
   user-specified encoding before it is sent to :func:`urlopen` as the optional
 
513
   *data* argument.
511
514
   The resulting string is a series of ``key=value`` pairs separated by ``'&'``
512
515
   characters, where both *key* and *value* are quoted using :func:`quote_plus`
513
516
   above. When a sequence of two-element tuples is used as the *query*
524
527
   To reverse this encoding process, :func:`parse_qs` and :func:`parse_qsl` are
525
528
   provided in this module to parse query strings into Python data structures.
526
529
 
 
530
   Refer to :ref:`urllib examples <urllib-examples>` to find out how urlencode
 
531
   method can be used for generating query string for a URL or data for POST.
 
532
 
527
533
   .. versionchanged:: 3.2
528
534
      Query parameter supports bytes and string objects.
529
535