Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4d76e6

Browse files
committed
#13251: update string description in datamodel.rst.
1 parent f602c55 commit f4d76e6

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

Doc/reference/datamodel.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,16 @@ Sequences
276276
single: integer
277277
single: Unicode
278278

279-
The items of a string object are Unicode code units. A Unicode code
280-
unit is represented by a string object of one item and can hold either
281-
a 16-bit or 32-bit value representing a Unicode ordinal (the maximum
282-
value for the ordinal is given in ``sys.maxunicode``, and depends on
283-
how Python is configured at compile time). Surrogate pairs may be
284-
present in the Unicode object, and will be reported as two separate
285-
items. The built-in functions :func:`chr` and :func:`ord` convert
286-
between code units and nonnegative integers representing the Unicode
287-
ordinals as defined in the Unicode Standard 3.0. Conversion from and to
288-
other encodings are possible through the string method :meth:`encode`.
279+
A string is a sequence of values that represent Unicode codepoints.
280+
All the codepoints in range ``U+0000 - U+10FFFF`` can be represented
281+
in a string. Python doesn't have a :c:type:`chr` type, and
282+
every characters in the string is represented as a string object
283+
with length ``1``. The built-in function :func:`chr` converts a
284+
character to its codepoint (as an integer); :func:`ord` converts
285+
an integer in range ``0 - 10FFFF`` to the corresponding character.
286+
:meth:`str.encode` can be used to convert a :class:`str` to
287+
:class:`bytes` using the given encoding, and :meth:`bytes.decode` can
288+
be used to achieve the opposite.
289289

290290
Tuples
291291
.. index::

0 commit comments

Comments
 (0)