> **Источник:** https://python-all.ru/3.6/library/datatypes.html
>
> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.

---

# 8. Типы данных

Модули, описанные в этой главе, предоставляют разнообразные специализированные типы данных, такие как даты и время, массивы фиксированного типа, кучи (heap queues), синхронизированные очереди и множества.

Python также предоставляет несколько встроенных типов данных, в частности, [`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) – для хранения двоичных данных.

В этой главе описаны следующие модули:

- [8.1. `datetime` – Базовые типы даты и времени](https://python-all.ru/3.6/library/datetime.html)

  - [8.1.1. Доступные типы](https://python-all.ru/3.6/library/datetime.html#available-types)
  - [8.1.2. `timedelta` Объекты](https://python-all.ru/3.6/library/datetime.html#timedelta-objects)
  - [8.1.3. `date` Объекты](https://python-all.ru/3.6/library/datetime.html#date-objects)
  - [8.1.4. `datetime` Объекты](https://python-all.ru/3.6/library/datetime.html#datetime-objects)
  - [8.1.5. `time` Объекты](https://python-all.ru/3.6/library/datetime.html#time-objects)
  - [8.1.6. `tzinfo` Объекты](https://python-all.ru/3.6/library/datetime.html#tzinfo-objects)
  - [8.1.7. `timezone` Объекты](https://python-all.ru/3.6/library/datetime.html#timezone-objects)
  - [8.1.8. `strftime()` и `strptime()` Поведение](https://python-all.ru/3.6/library/datetime.html#strftime-and-strptime-behavior)
- [8.2. `calendar` – Общие функции, связанные с календарём](https://python-all.ru/3.6/library/calendar.html)
- [8.3. `collections` – Типы данных-контейнеры](https://python-all.ru/3.6/library/collections.html)

  - [8.3.1. `ChainMap` объекты](https://python-all.ru/3.6/library/collections.html#chainmap-objects)

    - [8.3.1.1. `ChainMap` Примеры и рецепты](https://python-all.ru/3.6/library/collections.html#chainmap-examples-and-recipes)
  - [8.3.2. `Counter` объекты](https://python-all.ru/3.6/library/collections.html#counter-objects)
  - [8.3.3. `deque` объекты](https://python-all.ru/3.6/library/collections.html#deque-objects)

    - [8.3.3.1. `deque` Рецепты](https://python-all.ru/3.6/library/collections.html#deque-recipes)
  - [8.3.4. `defaultdict` объекты](https://python-all.ru/3.6/library/collections.html#defaultdict-objects)

    - [8.3.4.1. `defaultdict` Примеры](https://python-all.ru/3.6/library/collections.html#defaultdict-examples)
  - [8.3.5. `namedtuple()` Фабричная функция для кортежей с именованными полями](https://python-all.ru/3.6/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields)
  - [8.3.6. `OrderedDict` объекты](https://python-all.ru/3.6/library/collections.html#ordereddict-objects)

    - [8.3.6.1. `OrderedDict` Примеры и рецепты](https://python-all.ru/3.6/library/collections.html#ordereddict-examples-and-recipes)
  - [8.3.7. `UserDict` объекты](https://python-all.ru/3.6/library/collections.html#userdict-objects)
  - [8.3.8. `UserList` объекты](https://python-all.ru/3.6/library/collections.html#userlist-objects)
  - [8.3.9. `UserString` объекты](https://python-all.ru/3.6/library/collections.html#userstring-objects)
- [8.4. `collections.abc` – Абстрактные базовые классы для контейнеров](https://python-all.ru/3.6/library/collections.abc.html)

  - [8.4.1. Абстрактные базовые классы коллекций](https://python-all.ru/3.6/library/collections.abc.html#collections-abstract-base-classes)
- [8.5. `heapq` – Алгоритм пирамидальной очереди](https://python-all.ru/3.6/library/heapq.html)

  - [8.5.1. Простые примеры](https://python-all.ru/3.6/library/heapq.html#basic-examples)
  - [8.5.2. Примечания по реализации очереди с приоритетом](https://python-all.ru/3.6/library/heapq.html#priority-queue-implementation-notes)
  - [8.5.3. Теория](https://python-all.ru/3.6/library/heapq.html#theory)
- [8.6. `bisect` – Алгоритм бинарного поиска в массиве](https://python-all.ru/3.6/library/bisect.html)

  - [8.6.1. Поиск в отсортированных списках](https://python-all.ru/3.6/library/bisect.html#searching-sorted-lists)
  - [8.6.2. Другие примеры](https://python-all.ru/3.6/library/bisect.html#other-examples)
- [8.7. `array` – эффективные массивы числовых значений](https://python-all.ru/3.6/library/array.html)
- [8.8. `weakref` – слабые ссылки](https://python-all.ru/3.6/library/weakref.html)

  - [8.8.1. Объекты слабых ссылок](https://python-all.ru/3.6/library/weakref.html#weak-reference-objects)
  - [8.8.2. Пример](https://python-all.ru/3.6/library/weakref.html#example)
  - [8.8.3. Объекты финализаторов](https://python-all.ru/3.6/library/weakref.html#finalizer-objects)
  - [8.8.4. Сравнение финализаторов с `__del__()` методами](https://python-all.ru/3.6/library/weakref.html#comparing-finalizers-with-del-methods)
- [8.9. `types` – динамическое создание типов и имена для встроенных типов](https://python-all.ru/3.6/library/types.html)

  - [8.9.1. Динамическое создание типов](https://python-all.ru/3.6/library/types.html#dynamic-type-creation)
  - [8.9.2. Стандартные типы интерпретатора](https://python-all.ru/3.6/library/types.html#standard-interpreter-types)
  - [8.9.3. Дополнительные служебные классы и функции](https://python-all.ru/3.6/library/types.html#additional-utility-classes-and-functions)
  - [8.9.4. Служебные функции для корутин](https://python-all.ru/3.6/library/types.html#coroutine-utility-functions)
- [8.10. `copy` – операции поверхностного и глубокого копирования](https://python-all.ru/3.6/library/copy.html)
- [8.11. `pprint` – форматированный вывод данных](https://python-all.ru/3.6/library/pprint.html)

  - [8.11.1. Объекты PrettyPrinter](https://python-all.ru/3.6/library/pprint.html#prettyprinter-objects)
  - [8.11.2. Пример](https://python-all.ru/3.6/library/pprint.html#example)
- [8.12. `reprlib` – альтернативная реализация `repr()`](https://python-all.ru/3.6/library/reprlib.html)

  - [8.12.1. Объекты Repr](https://python-all.ru/3.6/library/reprlib.html#repr-objects)
  - [8.12.2. Создание подклассов объектов Repr](https://python-all.ru/3.6/library/reprlib.html#subclassing-repr-objects)
- [8.13. `enum` – поддержка перечислений](https://python-all.ru/3.6/library/enum.html)

  - [8.13.1. Содержимое модуля](https://python-all.ru/3.6/library/enum.html#module-contents)
  - [8.13.2. Создание перечисления](https://python-all.ru/3.6/library/enum.html#creating-an-enum)
  - [8.13.3. Программный доступ к членам перечисления и их атрибутам](https://python-all.ru/3.6/library/enum.html#programmatic-access-to-enumeration-members-and-their-attributes)
  - [8.13.4. Дублирование членов и значений перечисления](https://python-all.ru/3.6/library/enum.html#duplicating-enum-members-and-values)
  - [8.13.5. Обеспечение уникальности значений перечисления](https://python-all.ru/3.6/library/enum.html#ensuring-unique-enumeration-values)
  - [8.13.6. Использование автоматических значений](https://python-all.ru/3.6/library/enum.html#using-automatic-values)
  - [8.13.7. Итерация](https://python-all.ru/3.6/library/enum.html#iteration)
  - [8.13.8. Сравнение](https://python-all.ru/3.6/library/enum.html#comparisons)
  - [8.13.9. Допустимые члены и атрибуты перечислений](https://python-all.ru/3.6/library/enum.html#allowed-members-and-attributes-of-enumerations)
  - [8.13.10. Ограниченное создание подклассов перечислений](https://python-all.ru/3.6/library/enum.html#restricted-subclassing-of-enumerations)
  - [8.13.11. Сериализация](https://python-all.ru/3.6/library/enum.html#pickling)
  - [8.13.12. Функциональный API](https://python-all.ru/3.6/library/enum.html#functional-api)
  - [8.13.13. Производные перечисления](https://python-all.ru/3.6/library/enum.html#derived-enumerations)

    - [8.13.13.1. IntEnum](https://python-all.ru/3.6/library/enum.html#intenum)
    - [8.13.13.2. IntFlag](https://python-all.ru/3.6/library/enum.html#intflag)
    - [8.13.13.3. Flag](https://python-all.ru/3.6/library/enum.html#flag)
    - [8.13.13.4. Другие](https://python-all.ru/3.6/library/enum.html#others)
  - [8.13.14. Интересные примеры](https://python-all.ru/3.6/library/enum.html#interesting-examples)

    - [8.13.14.1. Опускание значений](https://python-all.ru/3.6/library/enum.html#omitting-values)

      - [8.13.14.1.1. Использование `auto`](https://python-all.ru/3.6/library/enum.html#using-auto)
      - [8.13.14.1.2. Использование `object`](https://python-all.ru/3.6/library/enum.html#using-object)
      - [8.13.14.1.3. Использование описательной строки](https://python-all.ru/3.6/library/enum.html#using-a-descriptive-string)
      - [8.13.14.1.4. Использование пользовательского `__new__()`](https://python-all.ru/3.6/library/enum.html#using-a-custom-new)
    - [8.13.14.2. OrderedEnum](https://python-all.ru/3.6/library/enum.html#orderedenum)
    - [8.13.14.3. DuplicateFreeEnum](https://python-all.ru/3.6/library/enum.html#duplicatefreeenum)
    - [8.13.14.4. Planet](https://python-all.ru/3.6/library/enum.html#planet)
  - [8.13.15. Чем отличаются перечисления?](https://python-all.ru/3.6/library/enum.html#how-are-enums-different)

    - [8.13.15.1. Классы перечислений](https://python-all.ru/3.6/library/enum.html#enum-classes)
    - [8.13.15.2. Элементы перечислений (они же экземпляры)](https://python-all.ru/3.6/library/enum.html#enum-members-aka-instances)
    - [8.13.15.3. Тонкости](https://python-all.ru/3.6/library/enum.html#finer-points)

      - [8.13.15.3.1. Поддерживаемые `__dunder__` имена](https://python-all.ru/3.6/library/enum.html#supported-dunder-names)
      - [8.13.15.3.2. Поддерживаемые `_sunder_` имена](https://python-all.ru/3.6/library/enum.html#supported-sunder-names)
      - [8.13.15.3.3. `Enum` member type](https://python-all.ru/3.6/library/enum.html#enum-member-type)
      - [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)
      - [8.13.15.3.5. `Enum` classes with methods](https://python-all.ru/3.6/library/enum.html#enum-classes-with-methods)
      - [8.13.15.3.6. Combining members of `Flag`](https://python-all.ru/3.6/library/enum.html#combining-members-of-flag)
