Документация Python неофициальный перевод

datatypes.md

123 строк · 12.0 КБ · обычная страница · сырой текст · скачать

1> **Источник:** https://python-all.ru/3.7/library/datatypes.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# Типы данных89Модули, описанные в этой главе, предоставляют множество специализированных типов данных, таких как даты и время, массивы фиксированного типа, кучи, двусторонние очереди и перечисления.1011Python также предоставляет несколько встроенных типов данных, в частности, [`dict`](https://python-all.ru/3.7/library/stdtypes.html#dict), [`list`](https://python-all.ru/3.7/library/stdtypes.html#list), [`set`](https://python-all.ru/3.7/library/stdtypes.html#set), [`frozenset`](https://python-all.ru/3.7/library/stdtypes.html#frozenset) и [`tuple`](https://python-all.ru/3.7/library/stdtypes.html#tuple). Класс [`str`](https://python-all.ru/3.7/library/stdtypes.html#str) используется для хранения строк Unicode, а классы [`bytes`](https://python-all.ru/3.7/library/stdtypes.html#bytes) и [`bytearray`](https://python-all.ru/3.7/library/stdtypes.html#bytearray) используются для хранения двоичных данных.1213В этой главе описаны следующие модули:1415- [`datetime` – базовые типы даты и времени](https://python-all.ru/3.7/library/datetime.html)1617  - [Доступные типы](https://python-all.ru/3.7/library/datetime.html#available-types)18  - [Объекты `timedelta`](https://python-all.ru/3.7/library/datetime.html#timedelta-objects)19  - [Объекты `date`](https://python-all.ru/3.7/library/datetime.html#date-objects)20  - [Объекты `datetime`](https://python-all.ru/3.7/library/datetime.html#datetime-objects)21  - [Объекты `time`](https://python-all.ru/3.7/library/datetime.html#time-objects)22  - [Объекты `tzinfo`](https://python-all.ru/3.7/library/datetime.html#tzinfo-objects)23  - [Объекты `timezone`](https://python-all.ru/3.7/library/datetime.html#timezone-objects)24  - [Поведение `strftime()` и `strptime()`](https://python-all.ru/3.7/library/datetime.html#strftime-and-strptime-behavior)25- [`calendar` – общие функции для работы с календарём](https://python-all.ru/3.7/library/calendar.html)26- [`collections` – контейнерные типы данных](https://python-all.ru/3.7/library/collections.html)2728  - [`ChainMap` объекты](https://python-all.ru/3.7/library/collections.html#chainmap-objects)2930    - [Примеры и рецепты `ChainMap`](https://python-all.ru/3.7/library/collections.html#chainmap-examples-and-recipes)31  - [`Counter` объекты](https://python-all.ru/3.7/library/collections.html#counter-objects)32  - [`deque` объекты](https://python-all.ru/3.7/library/collections.html#deque-objects)3334    - [Рецепты `deque`](https://python-all.ru/3.7/library/collections.html#deque-recipes)35  - [`defaultdict` объекты](https://python-all.ru/3.7/library/collections.html#defaultdict-objects)3637    - [Примеры `defaultdict`](https://python-all.ru/3.7/library/collections.html#defaultdict-examples)38  - [`namedtuple()` – фабричная функция для кортежей с именованными полями](https://python-all.ru/3.7/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields)39  - [`OrderedDict` объекты](https://python-all.ru/3.7/library/collections.html#ordereddict-objects)4041    - [Примеры и рецепты `OrderedDict`](https://python-all.ru/3.7/library/collections.html#ordereddict-examples-and-recipes)42  - [`UserDict` объекты](https://python-all.ru/3.7/library/collections.html#userdict-objects)43  - [`UserList` объекты](https://python-all.ru/3.7/library/collections.html#userlist-objects)44  - [`UserString` объекты](https://python-all.ru/3.7/library/collections.html#userstring-objects)45- [`collections.abc` – абстрактные базовые классы для контейнеров](https://python-all.ru/3.7/library/collections.abc.html)4647  - [Абстрактные базовые классы коллекций](https://python-all.ru/3.7/library/collections.abc.html#collections-abstract-base-classes)48- [`heapq` – алгоритм кучи (очередь с приоритетом)](https://python-all.ru/3.7/library/heapq.html)4950  - [Основные примеры](https://python-all.ru/3.7/library/heapq.html#basic-examples)51  - [Примечания к реализации очереди с приоритетом](https://python-all.ru/3.7/library/heapq.html#priority-queue-implementation-notes)52  - [Теория](https://python-all.ru/3.7/library/heapq.html#theory)53- [`bisect` – алгоритм бисекции массива](https://python-all.ru/3.7/library/bisect.html)5455  - [Поиск в отсортированных списках](https://python-all.ru/3.7/library/bisect.html#searching-sorted-lists)56  - [Другие примеры](https://python-all.ru/3.7/library/bisect.html#other-examples)57- [`array` – эффективные массивы числовых значений](https://python-all.ru/3.7/library/array.html)58- [`weakref` – слабые ссылки](https://python-all.ru/3.7/library/weakref.html)5960  - [Объекты слабых ссылок](https://python-all.ru/3.7/library/weakref.html#weak-reference-objects)61  - [Пример](https://python-all.ru/3.7/library/weakref.html#example)62  - [Объекты финализаторов](https://python-all.ru/3.7/library/weakref.html#finalizer-objects)63  - [Сравнение финализаторов с методами `__del__()`](https://python-all.ru/3.7/library/weakref.html#comparing-finalizers-with-del-methods)64- [`types` – динамическое создание типов и имена для встроенных типов](https://python-all.ru/3.7/library/types.html)6566  - [Динамическое создание типов](https://python-all.ru/3.7/library/types.html#dynamic-type-creation)67  - [Стандартные типы интерпретатора](https://python-all.ru/3.7/library/types.html#standard-interpreter-types)68  - [Дополнительные вспомогательные классы и функции](https://python-all.ru/3.7/library/types.html#additional-utility-classes-and-functions)69  - [Вспомогательные функции для корутин](https://python-all.ru/3.7/library/types.html#coroutine-utility-functions)70- [`copy` – операции поверхностного и глубокого копирования](https://python-all.ru/3.7/library/copy.html)71- [`pprint` – форматированный вывод данных](https://python-all.ru/3.7/library/pprint.html)7273  - [Объекты PrettyPrinter](https://python-all.ru/3.7/library/pprint.html#prettyprinter-objects)74  - [Пример](https://python-all.ru/3.7/library/pprint.html#example)75- [`reprlib` – альтернативная `repr()` реализация](https://python-all.ru/3.7/library/reprlib.html)7677  - [Объекты Repr](https://python-all.ru/3.7/library/reprlib.html#repr-objects)78  - [Создание подклассов Repr](https://python-all.ru/3.7/library/reprlib.html#subclassing-repr-objects)79- [`enum` – поддержка перечислений](https://python-all.ru/3.7/library/enum.html)8081  - [Содержимое модуля](https://python-all.ru/3.7/library/enum.html#module-contents)82  - [Создание Enum](https://python-all.ru/3.7/library/enum.html#creating-an-enum)83  - [Программный доступ к элементам перечисления и их атрибутам](https://python-all.ru/3.7/library/enum.html#programmatic-access-to-enumeration-members-and-their-attributes)84  - [Дублирование элементов и значений перечисления](https://python-all.ru/3.7/library/enum.html#duplicating-enum-members-and-values)85  - [Обеспечение уникальности значений перечисления](https://python-all.ru/3.7/library/enum.html#ensuring-unique-enumeration-values)86  - [Использование автоматических значений](https://python-all.ru/3.7/library/enum.html#using-automatic-values)87  - [Итерация](https://python-all.ru/3.7/library/enum.html#iteration)88  - [Сравнения](https://python-all.ru/3.7/library/enum.html#comparisons)89  - [Допустимые элементы и атрибуты перечислений](https://python-all.ru/3.7/library/enum.html#allowed-members-and-attributes-of-enumerations)90  - [Ограниченное создание подклассов Enum](https://python-all.ru/3.7/library/enum.html#restricted-enum-subclassing)91  - [Сериализация pickle](https://python-all.ru/3.7/library/enum.html#pickling)92  - [Функциональный API](https://python-all.ru/3.7/library/enum.html#functional-api)93  - [Производные перечисления](https://python-all.ru/3.7/library/enum.html#derived-enumerations)9495    - [IntEnum](https://python-all.ru/3.7/library/enum.html#intenum)96    - [IntFlag](https://python-all.ru/3.7/library/enum.html#intflag)97    - [Flag](https://python-all.ru/3.7/library/enum.html#flag)98    - [Другие](https://python-all.ru/3.7/library/enum.html#others)99  - [Интересные примеры](https://python-all.ru/3.7/library/enum.html#interesting-examples)100101    - [Пропуск значений](https://python-all.ru/3.7/library/enum.html#omitting-values)102103      - [Использование `auto`](https://python-all.ru/3.7/library/enum.html#using-auto)104      - [Использование `object`](https://python-all.ru/3.7/library/enum.html#using-object)105      - [Использование описательной строки](https://python-all.ru/3.7/library/enum.html#using-a-descriptive-string)106      - [Использование пользовательского `__new__()`](https://python-all.ru/3.7/library/enum.html#using-a-custom-new)107    - [OrderedEnum](https://python-all.ru/3.7/library/enum.html#orderedenum)108    - [DuplicateFreeEnum](https://python-all.ru/3.7/library/enum.html#duplicatefreeenum)109    - [Планета](https://python-all.ru/3.7/library/enum.html#planet)110    - [ВременнойПериод](https://python-all.ru/3.7/library/enum.html#timeperiod)111  - [Чем различаются перечисления?](https://python-all.ru/3.7/library/enum.html#how-are-enums-different)112113    - [Классы Enum](https://python-all.ru/3.7/library/enum.html#enum-classes)114    - [Члены Enum (экземпляры)](https://python-all.ru/3.7/library/enum.html#enum-members-aka-instances)115    - [Тонкие моменты](https://python-all.ru/3.7/library/enum.html#finer-points)116117      - [Поддерживаемые `__dunder__` имена](https://python-all.ru/3.7/library/enum.html#supported-dunder-names)118      - [Поддерживаемые `_sunder_` имена](https://python-all.ru/3.7/library/enum.html#supported-sunder-names)119      - [Тип элемента `Enum`](https://python-all.ru/3.7/library/enum.html#enum-member-type)120      - [Логическое значение классов и элементов `Enum`](https://python-all.ru/3.7/library/enum.html#boolean-value-of-enum-classes-and-members)121      - [Классы `Enum` с методами](https://python-all.ru/3.7/library/enum.html#enum-classes-with-methods)122      - [Объединение элементов `Flag`](https://python-all.ru/3.7/library/enum.html#combining-members-of-flag)123