> **Источник:** https://python-all.ru/2.7/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, unicode, list, tuple, bytearray, buffer, xrange](https://python-all.ru/2.7/library/stdtypes.html#typesseq), а также строковые методы, описанные в разделе [Строковые методы](https://python-all.ru/2.7/library/stdtypes.html#string-methods). Для вывода форматированных строк используйте шаблонные строки или оператор `%`, описанный в разделе [Операции форматирования строк](https://python-all.ru/2.7/library/stdtypes.html#string-formatting). Также смотрите модуль [`re`](https://python-all.ru/2.7/library/re.html#module-re) для строковых функций на основе регулярных выражений.

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

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

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

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

    - [7.2.5.1. Проверка пары](https://python-all.ru/2.7/library/re.html#checking-for-a-pair)
    - [7.2.5.2. Имитация scanf()](https://python-all.ru/2.7/library/re.html#simulating-scanf)
    - [7.2.5.3. search() и match()](https://python-all.ru/2.7/library/re.html#search-vs-match)
    - [7.2.5.4. Создание телефонной книги](https://python-all.ru/2.7/library/re.html#making-a-phonebook)
    - [7.2.5.5. Обработка текста](https://python-all.ru/2.7/library/re.html#text-munging)
    - [7.2.5.6. Поиск всех наречий](https://python-all.ru/2.7/library/re.html#finding-all-adverbs)
    - [7.2.5.7. Поиск всех наречий и их позиций](https://python-all.ru/2.7/library/re.html#finding-all-adverbs-and-their-positions)
    - [7.2.5.8. Сырые строки](https://python-all.ru/2.7/library/re.html#raw-string-notation)
- [7.3. `struct` – Интерпретация строк как упакованных двоичных данных](https://python-all.ru/2.7/library/struct.html)

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

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

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

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

    - [7.8.1.1. Объекты кодеков](https://python-all.ru/2.7/library/codecs.html#codec-objects)
    - [7.8.1.2. Объекты IncrementalEncoder](https://python-all.ru/2.7/library/codecs.html#incrementalencoder-objects)
    - [7.8.1.3. Объекты IncrementalDecoder](https://python-all.ru/2.7/library/codecs.html#incrementaldecoder-objects)
    - [7.8.1.4. Объекты StreamWriter](https://python-all.ru/2.7/library/codecs.html#streamwriter-objects)
    - [7.8.1.5. Объекты StreamReader](https://python-all.ru/2.7/library/codecs.html#streamreader-objects)
    - [7.8.1.6. Объекты StreamReaderWriter](https://python-all.ru/2.7/library/codecs.html#streamreaderwriter-objects)
    - [7.8.1.7. Объекты StreamRecoder](https://python-all.ru/2.7/library/codecs.html#streamrecoder-objects)
  - [7.8.2. Кодировки и Unicode](https://python-all.ru/2.7/library/codecs.html#encodings-and-unicode)
  - [7.8.3. Стандартные кодировки](https://python-all.ru/2.7/library/codecs.html#standard-encodings)
  - [7.8.4. Специфические для Python кодировки](https://python-all.ru/2.7/library/codecs.html#python-specific-encodings)
  - [7.8.5. `encodings.idna` – Интернационализированные доменные имена в приложениях](https://python-all.ru/2.7/library/codecs.html#module-encodings.idna)
  - [7.8.6. `encodings.utf_8_sig` – Кодек UTF-8 с сигнатурой BOM](https://python-all.ru/2.7/library/codecs.html#module-encodings.utf_8_sig)
- [7.9. `unicodedata` – База данных Unicode](https://python-all.ru/2.7/library/unicodedata.html)
- [7.10. `stringprep` – Подготовка интернет-строк](https://python-all.ru/2.7/library/stringprep.html)
- [7.11. `fpformat` – Преобразования чисел с плавающей точкой](https://python-all.ru/2.7/library/fpformat.html)
