mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Issue #21667: Clarify string data model description
This commit is contained in:
parent
4a3f135c8d
commit
1462786f00
1 changed files with 10 additions and 9 deletions
|
|
@ -286,15 +286,16 @@ Sequences
|
||||||
single: Unicode
|
single: Unicode
|
||||||
|
|
||||||
A string is a sequence of values that represent Unicode code points.
|
A string is a sequence of values that represent Unicode code points.
|
||||||
All the codepoints in range ``U+0000 - U+10FFFF`` can be represented
|
All the code points in the range ``U+0000 - U+10FFFF`` can be
|
||||||
in a string. Python doesn't have a :c:type:`chr` type, and
|
represented in a string. Python doesn't have a :c:type:`char` type;
|
||||||
every character in the string is represented as a string object
|
instead, every code point in the string is represented as a string
|
||||||
with length ``1``. The built-in function :func:`ord` converts a
|
object with length ``1``. The built-in function :func:`ord`
|
||||||
character to its codepoint (as an integer); :func:`chr` converts
|
converts a code point from its string form to an integer in the
|
||||||
an integer in range ``0 - 10FFFF`` to the corresponding character.
|
range ``0 - 10FFFF``; :func:`chr` converts an integer in the range
|
||||||
|
``0 - 10FFFF`` to the corresponding length ``1`` string object.
|
||||||
:meth:`str.encode` can be used to convert a :class:`str` to
|
:meth:`str.encode` can be used to convert a :class:`str` to
|
||||||
:class:`bytes` using the given encoding, and :meth:`bytes.decode` can
|
:class:`bytes` using the given text encoding, and
|
||||||
be used to achieve the opposite.
|
:meth:`bytes.decode` can be used to achieve the opposite.
|
||||||
|
|
||||||
Tuples
|
Tuples
|
||||||
.. index::
|
.. index::
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue