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

datatypes.md

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

1> **Источник:** https://python-all.ru/3.6/library/datatypes.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# 8. Типы данных89Модули, описанные в этой главе, предоставляют разнообразные специализированные типы данных, такие как даты и время, массивы фиксированного типа, кучи (heap queues), синхронизированные очереди и множества.1011Python также предоставляет несколько встроенных типов данных, в частности, [`dict`](https://python-all.ru/3.6/library/stdtypes.html#dict), [`list`](https://python-all.ru/3.6/library/stdtypes.html#list), [`set`](https://python-all.ru/3.6/library/stdtypes.html#set) и [`frozenset`](https://python-all.ru/3.6/library/stdtypes.html#frozenset), и [`tuple`](https://python-all.ru/3.6/library/stdtypes.html#tuple). Класс [`str`](https://python-all.ru/3.6/library/stdtypes.html#str) используется для хранения строк Unicode, а класс [`bytes`](https://python-all.ru/3.6/library/stdtypes.html#bytes) – для хранения двоичных данных.1213В этой главе описаны следующие модули:1415- [8.1. `datetime` – Базовые типы даты и времени](https://python-all.ru/3.6/library/datetime.html)1617  - [8.1.1. Доступные типы](https://python-all.ru/3.6/library/datetime.html#available-types)18  - [8.1.2. `timedelta` Объекты](https://python-all.ru/3.6/library/datetime.html#timedelta-objects)19  - [8.1.3. `date` Объекты](https://python-all.ru/3.6/library/datetime.html#date-objects)20  - [8.1.4. `datetime` Объекты](https://python-all.ru/3.6/library/datetime.html#datetime-objects)21  - [8.1.5. `time` Объекты](https://python-all.ru/3.6/library/datetime.html#time-objects)22  - [8.1.6. `tzinfo` Объекты](https://python-all.ru/3.6/library/datetime.html#tzinfo-objects)23  - [8.1.7. `timezone` Объекты](https://python-all.ru/3.6/library/datetime.html#timezone-objects)24  - [8.1.8. `strftime()` и `strptime()` Поведение](https://python-all.ru/3.6/library/datetime.html#strftime-and-strptime-behavior)25- [8.2. `calendar` – Общие функции, связанные с календарём](https://python-all.ru/3.6/library/calendar.html)26- [8.3. `collections` – Типы данных-контейнеры](https://python-all.ru/3.6/library/collections.html)2728  - [8.3.1. `ChainMap` объекты](https://python-all.ru/3.6/library/collections.html#chainmap-objects)2930    - [8.3.1.1. `ChainMap` Примеры и рецепты](https://python-all.ru/3.6/library/collections.html#chainmap-examples-and-recipes)31  - [8.3.2. `Counter` объекты](https://python-all.ru/3.6/library/collections.html#counter-objects)32  - [8.3.3. `deque` объекты](https://python-all.ru/3.6/library/collections.html#deque-objects)3334    - [8.3.3.1. `deque` Рецепты](https://python-all.ru/3.6/library/collections.html#deque-recipes)35  - [8.3.4. `defaultdict` объекты](https://python-all.ru/3.6/library/collections.html#defaultdict-objects)3637    - [8.3.4.1. `defaultdict` Примеры](https://python-all.ru/3.6/library/collections.html#defaultdict-examples)38  - [8.3.5. `namedtuple()` Фабричная функция для кортежей с именованными полями](https://python-all.ru/3.6/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields)39  - [8.3.6. `OrderedDict` объекты](https://python-all.ru/3.6/library/collections.html#ordereddict-objects)4041    - [8.3.6.1. `OrderedDict` Примеры и рецепты](https://python-all.ru/3.6/library/collections.html#ordereddict-examples-and-recipes)42  - [8.3.7. `UserDict` объекты](https://python-all.ru/3.6/library/collections.html#userdict-objects)43  - [8.3.8. `UserList` объекты](https://python-all.ru/3.6/library/collections.html#userlist-objects)44  - [8.3.9. `UserString` объекты](https://python-all.ru/3.6/library/collections.html#userstring-objects)45- [8.4. `collections.abc` – Абстрактные базовые классы для контейнеров](https://python-all.ru/3.6/library/collections.abc.html)4647  - [8.4.1. Абстрактные базовые классы коллекций](https://python-all.ru/3.6/library/collections.abc.html#collections-abstract-base-classes)48- [8.5. `heapq` – Алгоритм пирамидальной очереди](https://python-all.ru/3.6/library/heapq.html)4950  - [8.5.1. Простые примеры](https://python-all.ru/3.6/library/heapq.html#basic-examples)51  - [8.5.2. Примечания по реализации очереди с приоритетом](https://python-all.ru/3.6/library/heapq.html#priority-queue-implementation-notes)52  - [8.5.3. Теория](https://python-all.ru/3.6/library/heapq.html#theory)53- [8.6. `bisect` – Алгоритм бинарного поиска в массиве](https://python-all.ru/3.6/library/bisect.html)5455  - [8.6.1. Поиск в отсортированных списках](https://python-all.ru/3.6/library/bisect.html#searching-sorted-lists)56  - [8.6.2. Другие примеры](https://python-all.ru/3.6/library/bisect.html#other-examples)57- [8.7. `array` – эффективные массивы числовых значений](https://python-all.ru/3.6/library/array.html)58- [8.8. `weakref` – слабые ссылки](https://python-all.ru/3.6/library/weakref.html)5960  - [8.8.1. Объекты слабых ссылок](https://python-all.ru/3.6/library/weakref.html#weak-reference-objects)61  - [8.8.2. Пример](https://python-all.ru/3.6/library/weakref.html#example)62  - [8.8.3. Объекты финализаторов](https://python-all.ru/3.6/library/weakref.html#finalizer-objects)63  - [8.8.4. Сравнение финализаторов с `__del__()` методами](https://python-all.ru/3.6/library/weakref.html#comparing-finalizers-with-del-methods)64- [8.9. `types` – динамическое создание типов и имена для встроенных типов](https://python-all.ru/3.6/library/types.html)6566  - [8.9.1. Динамическое создание типов](https://python-all.ru/3.6/library/types.html#dynamic-type-creation)67  - [8.9.2. Стандартные типы интерпретатора](https://python-all.ru/3.6/library/types.html#standard-interpreter-types)68  - [8.9.3. Дополнительные служебные классы и функции](https://python-all.ru/3.6/library/types.html#additional-utility-classes-and-functions)69  - [8.9.4. Служебные функции для корутин](https://python-all.ru/3.6/library/types.html#coroutine-utility-functions)70- [8.10. `copy` – операции поверхностного и глубокого копирования](https://python-all.ru/3.6/library/copy.html)71- [8.11. `pprint` – форматированный вывод данных](https://python-all.ru/3.6/library/pprint.html)7273  - [8.11.1. Объекты PrettyPrinter](https://python-all.ru/3.6/library/pprint.html#prettyprinter-objects)74  - [8.11.2. Пример](https://python-all.ru/3.6/library/pprint.html#example)75- [8.12. `reprlib` – альтернативная реализация `repr()`](https://python-all.ru/3.6/library/reprlib.html)7677  - [8.12.1. Объекты Repr](https://python-all.ru/3.6/library/reprlib.html#repr-objects)78  - [8.12.2. Создание подклассов объектов Repr](https://python-all.ru/3.6/library/reprlib.html#subclassing-repr-objects)79- [8.13. `enum` – поддержка перечислений](https://python-all.ru/3.6/library/enum.html)8081  - [8.13.1. Содержимое модуля](https://python-all.ru/3.6/library/enum.html#module-contents)82  - [8.13.2. Создание перечисления](https://python-all.ru/3.6/library/enum.html#creating-an-enum)83  - [8.13.3. Программный доступ к членам перечисления и их атрибутам](https://python-all.ru/3.6/library/enum.html#programmatic-access-to-enumeration-members-and-their-attributes)84  - [8.13.4. Дублирование членов и значений перечисления](https://python-all.ru/3.6/library/enum.html#duplicating-enum-members-and-values)85  - [8.13.5. Обеспечение уникальности значений перечисления](https://python-all.ru/3.6/library/enum.html#ensuring-unique-enumeration-values)86  - [8.13.6. Использование автоматических значений](https://python-all.ru/3.6/library/enum.html#using-automatic-values)87  - [8.13.7. Итерация](https://python-all.ru/3.6/library/enum.html#iteration)88  - [8.13.8. Сравнение](https://python-all.ru/3.6/library/enum.html#comparisons)89  - [8.13.9. Допустимые члены и атрибуты перечислений](https://python-all.ru/3.6/library/enum.html#allowed-members-and-attributes-of-enumerations)90  - [8.13.10. Ограниченное создание подклассов перечислений](https://python-all.ru/3.6/library/enum.html#restricted-subclassing-of-enumerations)91  - [8.13.11. Сериализация](https://python-all.ru/3.6/library/enum.html#pickling)92  - [8.13.12. Функциональный API](https://python-all.ru/3.6/library/enum.html#functional-api)93  - [8.13.13. Производные перечисления](https://python-all.ru/3.6/library/enum.html#derived-enumerations)9495    - [8.13.13.1. IntEnum](https://python-all.ru/3.6/library/enum.html#intenum)96    - [8.13.13.2. IntFlag](https://python-all.ru/3.6/library/enum.html#intflag)97    - [8.13.13.3. Flag](https://python-all.ru/3.6/library/enum.html#flag)98    - [8.13.13.4. Другие](https://python-all.ru/3.6/library/enum.html#others)99  - [8.13.14. Интересные примеры](https://python-all.ru/3.6/library/enum.html#interesting-examples)100101    - [8.13.14.1. Опускание значений](https://python-all.ru/3.6/library/enum.html#omitting-values)102103      - [8.13.14.1.1. Использование `auto`](https://python-all.ru/3.6/library/enum.html#using-auto)104      - [8.13.14.1.2. Использование `object`](https://python-all.ru/3.6/library/enum.html#using-object)105      - [8.13.14.1.3. Использование описательной строки](https://python-all.ru/3.6/library/enum.html#using-a-descriptive-string)106      - [8.13.14.1.4. Использование пользовательского `__new__()`](https://python-all.ru/3.6/library/enum.html#using-a-custom-new)107    - [8.13.14.2. OrderedEnum](https://python-all.ru/3.6/library/enum.html#orderedenum)108    - [8.13.14.3. DuplicateFreeEnum](https://python-all.ru/3.6/library/enum.html#duplicatefreeenum)109    - [8.13.14.4. Planet](https://python-all.ru/3.6/library/enum.html#planet)110  - [8.13.15. Чем отличаются перечисления?](https://python-all.ru/3.6/library/enum.html#how-are-enums-different)111112    - [8.13.15.1. Классы перечислений](https://python-all.ru/3.6/library/enum.html#enum-classes)113    - [8.13.15.2. Элементы перечислений (они же экземпляры)](https://python-all.ru/3.6/library/enum.html#enum-members-aka-instances)114    - [8.13.15.3. Тонкости](https://python-all.ru/3.6/library/enum.html#finer-points)115116      - [8.13.15.3.1. Поддерживаемые `__dunder__` имена](https://python-all.ru/3.6/library/enum.html#supported-dunder-names)117      - [8.13.15.3.2. Поддерживаемые `_sunder_` имена](https://python-all.ru/3.6/library/enum.html#supported-sunder-names)118      - [8.13.15.3.3. `Enum` member type](https://python-all.ru/3.6/library/enum.html#enum-member-type)119      - [8.13.15.3.4. Boolean value of `Enum` classes and members](https://python-all.ru/3.6/library/enum.html#boolean-value-of-enum-classes-and-members)120      - [8.13.15.3.5. `Enum` classes with methods](https://python-all.ru/3.6/library/enum.html#enum-classes-with-methods)121      - [8.13.15.3.6. Combining members of `Flag`](https://python-all.ru/3.6/library/enum.html#combining-members-of-flag)122