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

---

# 7. Строковые службы

The modules described in this chapter provide a wide range of string manipulation operations.

В дополнение, встроенные строковые классы Python поддерживают методы последовательностей, описанные в разделе [*Типы последовательностей – str, bytes, bytearray, list, tuple, range*](https://python-all.ru/3.1/library/stdtypes.html#typesseq), а также строковые методы, описанные в разделе [*Строковые методы*](https://python-all.ru/3.1/library/stdtypes.html#string-methods). Для форматирования строк см. раздел [*Форматирование строк*](https://python-all.ru/3.1/library/string.html#string-formatting). Также см. модуль [`re`](https://python-all.ru/3.1/library/re.html#module-re) для строковых функций, основанных на регулярных выражениях.

- [7.1. `string` – Основные операции со строками](https://python-all.ru/3.1/library/string.html)

  - [7.1.1. Константы строк](https://python-all.ru/3.1/library/string.html#string-constants)
  - [7.1.2. Форматирование строк](https://python-all.ru/3.1/library/string.html#string-formatting)
  - [7.1.3. Синтаксис строк форматирования](https://python-all.ru/3.1/library/string.html#format-string-syntax)

    - [7.1.3.1. Мини-язык спецификации форматирования](https://python-all.ru/3.1/library/string.html#format-specification-mini-language)
    - [7.1.3.2. Примеры форматирования](https://python-all.ru/3.1/library/string.html#format-examples)
  - [7.1.4. Шаблонные строки](https://python-all.ru/3.1/library/string.html#template-strings)
  - [7.1.5. Вспомогательные функции](https://python-all.ru/3.1/library/string.html#helper-functions)
- [7.2. `re` – Регулярные выражения](https://python-all.ru/3.1/library/re.html)

  - [7.2.1. Синтаксис регулярных выражений](https://python-all.ru/3.1/library/re.html#regular-expression-syntax)
  - [7.2.2. Сопоставление и поиск](https://python-all.ru/3.1/library/re.html#matching-vs-searching)
  - [7.2.3. Содержимое модуля](https://python-all.ru/3.1/library/re.html#module-contents)
  - [7.2.4. Объекты регулярных выражений](https://python-all.ru/3.1/library/re.html#regular-expression-objects)
  - [7.2.5. Объекты совпадений](https://python-all.ru/3.1/library/re.html#match-objects)
  - [7.2.6. Примеры](https://python-all.ru/3.1/library/re.html#examples)

    - [7.2.6.1. Проверка на пару](https://python-all.ru/3.1/library/re.html#checking-for-a-pair)
    - [7.2.6.2. Имитация scanf()](https://python-all.ru/3.1/library/re.html#simulating-scanf)
    - [7.2.6.3. Избегание рекурсии](https://python-all.ru/3.1/library/re.html#avoiding-recursion)
    - [7.2.6.4. search() против match()](https://python-all.ru/3.1/library/re.html#search-vs-match)
    - [7.2.6.5. Создание телефонной книги](https://python-all.ru/3.1/library/re.html#making-a-phonebook)
    - [7.2.6.6. Обработка текста](https://python-all.ru/3.1/library/re.html#text-munging)
    - [7.2.6.7. Поиск всех наречий](https://python-all.ru/3.1/library/re.html#finding-all-adverbs)
    - [7.2.6.8. Поиск всех наречий и их позиций](https://python-all.ru/3.1/library/re.html#finding-all-adverbs-and-their-positions)
    - [7.2.6.9. Сырые строки](https://python-all.ru/3.1/library/re.html#raw-string-notation)
- [7.3. `struct` – Интерпретация байтов как упакованных двоичных данных](https://python-all.ru/3.1/library/struct.html)

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

    - [7.3.2.1. Порядок байтов, размер и выравнивание](https://python-all.ru/3.1/library/struct.html#byte-order-size-and-alignment)
    - [7.3.2.2. Символы формата](https://python-all.ru/3.1/library/struct.html#format-characters)
    - [7.3.2.3. Примеры](https://python-all.ru/3.1/library/struct.html#examples)
  - [7.3.3. Классы](https://python-all.ru/3.1/library/struct.html#classes)
- [7.4. `difflib` – Вспомогательные функции для вычисления различий](https://python-all.ru/3.1/library/difflib.html)

  - [7.4.1. Объекты SequenceMatcher](https://python-all.ru/3.1/library/difflib.html#sequencematcher-objects)
  - [7.4.2. Примеры SequenceMatcher](https://python-all.ru/3.1/library/difflib.html#sequencematcher-examples)
  - [7.4.3. Объекты Differ](https://python-all.ru/3.1/library/difflib.html#differ-objects)
  - [7.4.4. Пример Differ](https://python-all.ru/3.1/library/difflib.html#differ-example)
  - [7.4.5. Интерфейс командной строки для difflib](https://python-all.ru/3.1/library/difflib.html#a-command-line-interface-to-difflib)
- [7.5. `textwrap` – Перенос и заполнение текста](https://python-all.ru/3.1/library/textwrap.html)
- [7.6. `codecs` – Реестр кодеков и базовые классы](https://python-all.ru/3.1/library/codecs.html)

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

    - [7.6.1.1. Объекты Codec](https://python-all.ru/3.1/library/codecs.html#codec-objects)
    - [7.6.1.2. Объекты IncrementalEncoder](https://python-all.ru/3.1/library/codecs.html#incrementalencoder-objects)
    - [7.6.1.3. Объекты IncrementalDecoder](https://python-all.ru/3.1/library/codecs.html#incrementaldecoder-objects)
    - [7.6.1.4. Объекты StreamWriter](https://python-all.ru/3.1/library/codecs.html#streamwriter-objects)
    - [7.6.1.5. Объекты StreamReader](https://python-all.ru/3.1/library/codecs.html#streamreader-objects)
    - [7.6.1.6. Объекты StreamReaderWriter](https://python-all.ru/3.1/library/codecs.html#streamreaderwriter-objects)
    - [7.6.1.7. Объекты StreamRecoder](https://python-all.ru/3.1/library/codecs.html#streamrecoder-objects)
  - [7.6.2. Кодировки и Unicode](https://python-all.ru/3.1/library/codecs.html#encodings-and-unicode)
  - [7.6.3. Стандартные кодировки](https://python-all.ru/3.1/library/codecs.html#standard-encodings)
  - [7.6.4. `encodings.idna` – Интернационализированные доменные имена в приложениях](https://python-all.ru/3.1/library/codecs.html#module-encodings.idna)
  - [7.6.5. `encodings.utf_8_sig` – Кодек UTF-8 с сигнатурой BOM](https://python-all.ru/3.1/library/codecs.html#module-encodings.utf_8_sig)
- [7.7. `unicodedata` – База данных Unicode](https://python-all.ru/3.1/library/unicodedata.html)
- [7.8. `stringprep` – Подготовка строк для интернета](https://python-all.ru/3.1/library/stringprep.html)
