@@ -42,8 +42,8 @@ or on combining URL components into a URL string.
42
42
Parse a URL into six components, returning a 6-item :term: `named tuple `. This
43
43
corresponds to the general structure of a URL:
44
44
``scheme://netloc/path;parameters?query#fragment ``.
45
- Each tuple item is a string, possibly empty. The components are not broken up in
46
- smaller parts (for example, the network location is a single string), and %
45
+ Each tuple item is a string, possibly empty. The components are not broken up
46
+ into smaller parts (for example, the network location is a single string), and %
47
47
escapes are not expanded. The delimiters as shown above are not part of the
48
48
result, except for a leading slash in the *path * component, which is retained if
49
49
present. For example:
@@ -328,22 +328,22 @@ or on combining URL components into a URL string.
328
328
329
329
.. note ::
330
330
331
- If *url * is an absolute URL (that is, starting with ``// `` or ``scheme:// ``),
332
- the *url *'s host name and/or scheme will be present in the result. For example:
331
+ If *url * is an absolute URL (that is, it starts with ``// `` or ``scheme:// ``),
332
+ the *url *'s hostname and/or scheme will be present in the result. For example:
333
333
334
- .. doctest ::
334
+ .. doctest ::
335
335
336
- >>> urljoin(' http://www.cwi.nl/%7E guido/Python.html' ,
337
- ... ' //www.python.org/%7E guido' )
338
- 'http://www.python.org/%7Eguido'
336
+ >>> urljoin(' http://www.cwi.nl/%7E guido/Python.html' ,
337
+ ... ' //www.python.org/%7E guido' )
338
+ 'http://www.python.org/%7Eguido'
339
339
340
- If you do not want that behavior, preprocess the *url * with :func: `urlsplit ` and
341
- :func: `urlunsplit `, removing possible *scheme * and *netloc * parts.
340
+ If you do not want that behavior, preprocess the *url * with :func: `urlsplit ` and
341
+ :func: `urlunsplit `, removing possible *scheme * and *netloc * parts.
342
342
343
343
344
344
.. versionchanged :: 3.5
345
345
346
- Behaviour updated to match the semantics defined in :rfc: `3986 `.
346
+ Behavior updated to match the semantics defined in :rfc: `3986 `.
347
347
348
348
349
349
.. function :: urldefrag(url)
@@ -521,11 +521,11 @@ task isn't already covered by the URL parsing functions above.
521
521
522
522
Replace special characters in *string * using the ``%xx `` escape. Letters,
523
523
digits, and the characters ``'_.-~' `` are never quoted. By default, this
524
- function is intended for quoting the path section of URL. The optional * safe *
525
- parameter specifies additional ASCII characters that should not be quoted
526
- --- its default value is ``'/' ``.
524
+ function is intended for quoting the path section of a URL. The optional
525
+ * safe * parameter specifies additional ASCII characters that should not be
526
+ quoted --- its default value is ``'/' ``.
527
527
528
- *string * may be either a :class: `str ` or a :class: `bytes `.
528
+ *string * may be either a :class: `str ` or a :class: `bytes ` object .
529
529
530
530
.. versionchanged :: 3.7
531
531
Moved from :rfc: `2396 ` to :rfc: `3986 ` for quoting URL strings. "~" is now
@@ -547,7 +547,7 @@ task isn't already covered by the URL parsing functions above.
547
547
548
548
.. function :: quote_plus(string, safe='', encoding=None, errors=None)
549
549
550
- Like :func: `quote `, but also replace spaces by plus signs, as required for
550
+ Like :func: `quote `, but also replace spaces with plus signs, as required for
551
551
quoting HTML form values when building up a query string to go into a URL.
552
552
Plus signs in the original string are escaped unless they are included in
553
553
*safe *. It also does not have *safe * default to ``'/' ``.
@@ -566,12 +566,12 @@ task isn't already covered by the URL parsing functions above.
566
566
567
567
.. function :: unquote(string, encoding='utf-8', errors='replace')
568
568
569
- Replace ``%xx `` escapes by their single-character equivalent.
569
+ Replace ``%xx `` escapes with their single-character equivalent.
570
570
The optional *encoding * and *errors * parameters specify how to decode
571
571
percent-encoded sequences into Unicode characters, as accepted by the
572
572
:meth: `bytes.decode ` method.
573
573
574
- *string * may be either a :class: `str ` or a :class: `bytes `.
574
+ *string * may be either a :class: `str ` or a :class: `bytes ` object .
575
575
576
576
*encoding * defaults to ``'utf-8' ``.
577
577
*errors * defaults to ``'replace' ``, meaning invalid sequences are replaced
@@ -587,8 +587,8 @@ task isn't already covered by the URL parsing functions above.
587
587
588
588
.. function :: unquote_plus(string, encoding='utf-8', errors='replace')
589
589
590
- Like :func: `unquote `, but also replace plus signs by spaces, as required for
591
- unquoting HTML form values.
590
+ Like :func: `unquote `, but also replace plus signs with spaces, as required
591
+ for unquoting HTML form values.
592
592
593
593
*string * must be a :class: `str `.
594
594
@@ -597,10 +597,10 @@ task isn't already covered by the URL parsing functions above.
597
597
598
598
.. function :: unquote_to_bytes(string)
599
599
600
- Replace ``%xx `` escapes by their single-octet equivalent, and return a
600
+ Replace ``%xx `` escapes with their single-octet equivalent, and return a
601
601
:class: `bytes ` object.
602
602
603
- *string * may be either a :class: `str ` or a :class: `bytes `.
603
+ *string * may be either a :class: `str ` or a :class: `bytes ` object .
604
604
605
605
If it is a :class: `str `, unescaped non-ASCII characters in *string *
606
606
are encoded into UTF-8 bytes.
@@ -631,7 +631,7 @@ task isn't already covered by the URL parsing functions above.
631
631
When a sequence of two-element tuples is used as the *query *
632
632
argument, the first element of each tuple is a key and the second is a
633
633
value. The value element in itself can be a sequence and in that case, if
634
- the optional parameter *doseq * is evaluates to ``True ``, individual
634
+ the optional parameter *doseq * evaluates to ``True ``, individual
635
635
``key=value `` pairs separated by ``'&' `` are generated for each element of
636
636
the value sequence for the key. The order of parameters in the encoded
637
637
string will match the order of parameter tuples in the sequence.
@@ -643,11 +643,12 @@ task isn't already covered by the URL parsing functions above.
643
643
To reverse this encoding process, :func: `parse_qs ` and :func: `parse_qsl ` are
644
644
provided in this module to parse query strings into Python data structures.
645
645
646
- Refer to :ref: `urllib examples <urllib-examples >` to find out how urlencode
647
- method can be used for generating query string for a URL or data for POST.
646
+ Refer to :ref: `urllib examples <urllib-examples >` to find out how the
647
+ :func: `urllib.parse.urlencode ` method can be used for generating the query
648
+ string of a URL or data for a POST request.
648
649
649
650
.. versionchanged :: 3.2
650
- Query parameter supports bytes and string objects.
651
+ * query * supports bytes and string objects.
651
652
652
653
.. versionadded :: 3.5
653
654
*quote_via * parameter.
0 commit comments