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

---

# Службы двоичных данных

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

Некоторые библиотеки, описанные в [Службах обработки текста](https://python-all.ru/3/library/text.html#textservices), также работают либо с ASCII-совместимыми двоичными форматами (например, [`re`](https://python-all.ru/3/library/re.html#module-re)), либо со всеми двоичными данными (например, [`difflib`](https://python-all.ru/3/library/difflib.html#module-difflib)).

Кроме того, смотрите документацию по встроенным двоичным типам данных Python в [Двоичные типы последовательностей – bytes, bytearray, memoryview](https://python-all.ru/3/library/stdtypes.html#binaryseq).

- [`struct` – Интерпретация байтов как упакованных двоичных данных](https://python-all.ru/3/library/struct.html)

  - [Функции и исключения](https://python-all.ru/3/library/struct.html#functions-and-exceptions)
  - [Строки формата](https://python-all.ru/3/library/struct.html#format-strings)

    - [Порядок байтов, размер и выравнивание](https://python-all.ru/3/library/struct.html#byte-order-size-and-alignment)
    - [Символы форматирования](https://python-all.ru/3/library/struct.html#format-characters)
    - [Примеры](https://python-all.ru/3/library/struct.html#examples)
  - [Приложения](https://python-all.ru/3/library/struct.html#applications)

    - [Родные форматы](https://python-all.ru/3/library/struct.html#native-formats)
    - [Стандартные форматы](https://python-all.ru/3/library/struct.html#standard-formats)
  - [Классы](https://python-all.ru/3/library/struct.html#classes)
- [`codecs` – Реестр кодеков и базовые классы](https://python-all.ru/3/library/codecs.html)

  - [Базовые классы кодеков](https://python-all.ru/3/library/codecs.html#codec-base-classes)

    - [Обработчики ошибок](https://python-all.ru/3/library/codecs.html#error-handlers)
    - [Кодирование и декодирование без состояния](https://python-all.ru/3/library/codecs.html#stateless-encoding-and-decoding)
    - [Инкрементное кодирование и декодирование](https://python-all.ru/3/library/codecs.html#incremental-encoding-and-decoding)

      - [Объекты IncrementalEncoder](https://python-all.ru/3/library/codecs.html#incrementalencoder-objects)
      - [Объекты IncrementalDecoder](https://python-all.ru/3/library/codecs.html#incrementaldecoder-objects)
    - [Потоковое кодирование и декодирование](https://python-all.ru/3/library/codecs.html#stream-encoding-and-decoding)

      - [Объекты StreamWriter](https://python-all.ru/3/library/codecs.html#streamwriter-objects)
      - [Объекты StreamReader](https://python-all.ru/3/library/codecs.html#streamreader-objects)
      - [Объекты StreamReaderWriter](https://python-all.ru/3/library/codecs.html#streamreaderwriter-objects)
      - [Объекты StreamRecoder](https://python-all.ru/3/library/codecs.html#streamrecoder-objects)
  - [Кодировки и Юникод](https://python-all.ru/3/library/codecs.html#encodings-and-unicode)
  - [Стандартные кодировки](https://python-all.ru/3/library/codecs.html#standard-encodings)
  - [Специфические для Python кодировки](https://python-all.ru/3/library/codecs.html#python-specific-encodings)

    - [Текстовые кодировки](https://python-all.ru/3/library/codecs.html#text-encodings)
    - [Двоичные преобразования](https://python-all.ru/3/library/codecs.html#binary-transforms)
    - [Автономные функции кодеков](https://python-all.ru/3/library/codecs.html#standalone-codec-functions)
    - [Текстовые преобразования](https://python-all.ru/3/library/codecs.html#text-transforms)
  - [`encodings` – пакет кодировок](https://python-all.ru/3/library/codecs.html#module-encodings)
  - [`encodings.idna` – интернационализированные доменные имена в приложениях](https://python-all.ru/3/library/codecs.html#module-encodings.idna)
  - [`encodings.mbcs` – кодовая страница ANSI Windows](https://python-all.ru/3/library/codecs.html#module-encodings.mbcs)
  - [`encodings.utf_8_sig` – кодек UTF-8 с сигнатурой BOM](https://python-all.ru/3/library/codecs.html#module-encodings.utf_8_sig)
