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

---

# 16. Универсальные службы операционной системы

Модули, описанные в этой главе, предоставляют интерфейсы к возможностям операционной системы, доступным (почти) во всех ОС, таким как файлы и часы. Интерфейсы в основном смоделированы по образцу Unix- или C-интерфейсов, но они также доступны и в большинстве других систем. Вот обзор:

- [16.1. `os` – Разные интерфейсы операционной системы](https://python-all.ru/3.5/library/os.html)

  - [16.1.1. Имена файлов, аргументы командной строки и переменные окружения](https://python-all.ru/3.5/library/os.html#file-names-command-line-arguments-and-environment-variables)
  - [16.1.2. Параметры процесса](https://python-all.ru/3.5/library/os.html#process-parameters)
  - [16.1.3. Создание файловых объектов](https://python-all.ru/3.5/library/os.html#file-object-creation)
  - [16.1.4. Операции с файловыми дескрипторами](https://python-all.ru/3.5/library/os.html#file-descriptor-operations)

    - [16.1.4.1. Запрос размера терминала](https://python-all.ru/3.5/library/os.html#querying-the-size-of-a-terminal)
    - [16.1.4.2. Наследование файловых дескрипторов](https://python-all.ru/3.5/library/os.html#inheritance-of-file-descriptors)
  - [16.1.5. Файлы и каталоги](https://python-all.ru/3.5/library/os.html#files-and-directories)

    - [16.1.5.1. Расширенные атрибуты Linux](https://python-all.ru/3.5/library/os.html#linux-extended-attributes)
  - [16.1.6. Управление процессами](https://python-all.ru/3.5/library/os.html#process-management)
  - [16.1.7. Интерфейс к планировщику](https://python-all.ru/3.5/library/os.html#interface-to-the-scheduler)
  - [16.1.8. Разная системная информация](https://python-all.ru/3.5/library/os.html#miscellaneous-system-information)
  - [16.1.9. Прочие функции](https://python-all.ru/3.5/library/os.html#miscellaneous-functions)
- [16.2. `io` – Основные инструменты для работы с потоками](https://python-all.ru/3.5/library/io.html)

  - [16.2.1. Обзор](https://python-all.ru/3.5/library/io.html#overview)

    - [16.2.1.1. Текстовый ввод-вывод](https://python-all.ru/3.5/library/io.html#text-i-o)
    - [16.2.1.2. Двоичный ввод-вывод](https://python-all.ru/3.5/library/io.html#binary-i-o)
    - [16.2.1.3. Необработанный ввод-вывод](https://python-all.ru/3.5/library/io.html#raw-i-o)
  - [16.2.2. Интерфейс модуля высокого уровня](https://python-all.ru/3.5/library/io.html#high-level-module-interface)

    - [16.2.2.1. Потоки в памяти](https://python-all.ru/3.5/library/io.html#in-memory-streams)
  - [16.2.3. Иерархия классов](https://python-all.ru/3.5/library/io.html#class-hierarchy)

    - [16.2.3.1. Базовые классы ввода-вывода](https://python-all.ru/3.5/library/io.html#i-o-base-classes)
    - [16.2.3.2. Сырой файловый ввод-вывод](https://python-all.ru/3.5/library/io.html#raw-file-i-o)
    - [16.2.3.3. Буферизированные потоки данных](https://python-all.ru/3.5/library/io.html#buffered-streams)
    - [16.2.3.4. Текстовый ввод-вывод](https://python-all.ru/3.5/library/io.html#id1)
  - [16.2.4. Производительность](https://python-all.ru/3.5/library/io.html#performance)

    - [16.2.4.1. Двоичный ввод-вывод](https://python-all.ru/3.5/library/io.html#id2)
    - [16.2.4.2. Текстовый ввод-вывод](https://python-all.ru/3.5/library/io.html#id3)
    - [16.2.4.3. Многопоточность](https://python-all.ru/3.5/library/io.html#multi-threading)
    - [16.2.4.4. Реентерабельность](https://python-all.ru/3.5/library/io.html#reentrancy)
- [16.3. `time` – Доступ ко времени и преобразования](https://python-all.ru/3.5/library/time.html)
- [16.4. `argparse` – Парсер для параметров командной строки, аргументов и подкоманд](https://python-all.ru/3.5/library/argparse.html)

  - [16.4.1. Пример](https://python-all.ru/3.5/library/argparse.html#example)

    - [16.4.1.1. Создание парсера](https://python-all.ru/3.5/library/argparse.html#creating-a-parser)
    - [16.4.1.2. Добавление аргументов](https://python-all.ru/3.5/library/argparse.html#adding-arguments)
    - [16.4.1.3. Разбор аргументов](https://python-all.ru/3.5/library/argparse.html#parsing-arguments)
  - [16.4.2. Объекты ArgumentParser](https://python-all.ru/3.5/library/argparse.html#argumentparser-objects)

    - [16.4.2.1. prog](https://python-all.ru/3.5/library/argparse.html#prog)
    - [16.4.2.2. usage](https://python-all.ru/3.5/library/argparse.html#usage)
    - [16.4.2.3. description](https://python-all.ru/3.5/library/argparse.html#description)
    - [16.4.2.4. epilog](https://python-all.ru/3.5/library/argparse.html#epilog)
    - [16.4.2.5. parents](https://python-all.ru/3.5/library/argparse.html#parents)
    - [16.4.2.6. formatter\_class](https://python-all.ru/3.5/library/argparse.html#formatter-class)
    - [16.4.2.7. prefix\_chars](https://python-all.ru/3.5/library/argparse.html#prefix-chars)
    - [16.4.2.8. fromfile\_prefix\_chars](https://python-all.ru/3.5/library/argparse.html#fromfile-prefix-chars)
    - [16.4.2.9. argument\_default](https://python-all.ru/3.5/library/argparse.html#argument-default)
    - [16.4.2.10. allow\_abbrev](https://python-all.ru/3.5/library/argparse.html#allow-abbrev)
    - [16.4.2.11. conflict\_handler](https://python-all.ru/3.5/library/argparse.html#conflict-handler)
    - [16.4.2.12. add\_help](https://python-all.ru/3.5/library/argparse.html#add-help)
  - [16.4.3. Метод add\_argument()](https://python-all.ru/3.5/library/argparse.html#the-add-argument-method)

    - [16.4.3.1. Имя или флаги](https://python-all.ru/3.5/library/argparse.html#name-or-flags)
    - [16.4.3.2. action](https://python-all.ru/3.5/library/argparse.html#action)
    - [16.4.3.3. nargs](https://python-all.ru/3.5/library/argparse.html#nargs)
    - [16.4.3.4. const](https://python-all.ru/3.5/library/argparse.html#const)
    - [16.4.3.5. default](https://python-all.ru/3.5/library/argparse.html#default)
    - [16.4.3.6. type](https://python-all.ru/3.5/library/argparse.html#type)
    - [16.4.3.7. choices](https://python-all.ru/3.5/library/argparse.html#choices)
    - [16.4.3.8. required](https://python-all.ru/3.5/library/argparse.html#required)
    - [16.4.3.9. help](https://python-all.ru/3.5/library/argparse.html#help)
    - [16.4.3.10. metavar](https://python-all.ru/3.5/library/argparse.html#metavar)
    - [16.4.3.11. dest](https://python-all.ru/3.5/library/argparse.html#dest)
    - [16.4.3.12. Классы Action](https://python-all.ru/3.5/library/argparse.html#action-classes)
  - [16.4.4. Метод parse\_args()](https://python-all.ru/3.5/library/argparse.html#the-parse-args-method)

    - [16.4.4.1. Синтаксис значений параметров](https://python-all.ru/3.5/library/argparse.html#option-value-syntax)
    - [16.4.4.2. Недопустимые аргументы](https://python-all.ru/3.5/library/argparse.html#invalid-arguments)
    - [16.4.4.3. Аргументы, содержащие `-`](https://python-all.ru/3.5/library/argparse.html#arguments-containing)
    - [16.4.4.4. Сокращения аргументов (сопоставление по префиксу)](https://python-all.ru/3.5/library/argparse.html#argument-abbreviations-prefix-matching)
    - [16.4.4.5. За пределами `sys.argv`](https://python-all.ru/3.5/library/argparse.html#beyond-sys-argv)
    - [16.4.4.6. Объект Namespace](https://python-all.ru/3.5/library/argparse.html#the-namespace-object)
  - [16.4.5. Другие утилиты](https://python-all.ru/3.5/library/argparse.html#other-utilities)

    - [16.4.5.1. Подкоманды](https://python-all.ru/3.5/library/argparse.html#sub-commands)
    - [16.4.5.2. Объекты FileType](https://python-all.ru/3.5/library/argparse.html#filetype-objects)
    - [16.4.5.3. Группы аргументов](https://python-all.ru/3.5/library/argparse.html#argument-groups)
    - [16.4.5.4. Взаимное исключение](https://python-all.ru/3.5/library/argparse.html#mutual-exclusion)
    - [16.4.5.5. Значения парсера по умолчанию](https://python-all.ru/3.5/library/argparse.html#parser-defaults)
    - [16.4.5.6. Вывод справки](https://python-all.ru/3.5/library/argparse.html#printing-help)
    - [16.4.5.7. Частичный разбор](https://python-all.ru/3.5/library/argparse.html#partial-parsing)
    - [16.4.5.8. Настройка разбора файлов](https://python-all.ru/3.5/library/argparse.html#customizing-file-parsing)
    - [16.4.5.9. Методы выхода](https://python-all.ru/3.5/library/argparse.html#exiting-methods)
  - [16.4.6. Обновление кода optparse](https://python-all.ru/3.5/library/argparse.html#upgrading-optparse-code)
- [16.5. `getopt` – Парсер в стиле C для параметров командной строки](https://python-all.ru/3.5/library/getopt.html)
- [16.6. `logging` – Средство логирования для Python](https://python-all.ru/3.5/library/logging.html)

  - [16.6.1. Объекты Logger](https://python-all.ru/3.5/library/logging.html#logger-objects)
  - [16.6.2. Уровни логирования](https://python-all.ru/3.5/library/logging.html#logging-levels)
  - [16.6.3. Объекты-обработчики](https://python-all.ru/3.5/library/logging.html#handler-objects)
  - [16.6.4. Объекты-форматтеры](https://python-all.ru/3.5/library/logging.html#formatter-objects)
  - [16.6.5. Объекты-фильтры](https://python-all.ru/3.5/library/logging.html#filter-objects)
  - [16.6.6. Объекты LogRecord](https://python-all.ru/3.5/library/logging.html#logrecord-objects)
  - [16.6.7. Атрибуты LogRecord](https://python-all.ru/3.5/library/logging.html#logrecord-attributes)
  - [16.6.8. Объекты LoggerAdapter](https://python-all.ru/3.5/library/logging.html#loggeradapter-objects)
  - [16.6.9. Потокобезопасность](https://python-all.ru/3.5/library/logging.html#thread-safety)
  - [16.6.10. Функции уровня модуля](https://python-all.ru/3.5/library/logging.html#module-level-functions)
  - [16.6.11. Атрибуты уровня модуля](https://python-all.ru/3.5/library/logging.html#module-level-attributes)
  - [16.6.12. Интеграция с модулем warnings](https://python-all.ru/3.5/library/logging.html#integration-with-the-warnings-module)
- [16.7. `logging.config` – Конфигурация логирования](https://python-all.ru/3.5/library/logging.config.html)

  - [16.7.1. Функции конфигурации](https://python-all.ru/3.5/library/logging.config.html#configuration-functions)
  - [16.7.2. Схема словаря конфигурации](https://python-all.ru/3.5/library/logging.config.html#configuration-dictionary-schema)

    - [16.7.2.1. Детали схемы словаря](https://python-all.ru/3.5/library/logging.config.html#dictionary-schema-details)
    - [16.7.2.2. Инкрементальная конфигурация](https://python-all.ru/3.5/library/logging.config.html#incremental-configuration)
    - [16.7.2.3. Связи объектов](https://python-all.ru/3.5/library/logging.config.html#object-connections)
    - [16.7.2.4. Пользовательские объекты](https://python-all.ru/3.5/library/logging.config.html#user-defined-objects)
    - [16.7.2.5. Доступ к внешним объектам](https://python-all.ru/3.5/library/logging.config.html#access-to-external-objects)
    - [16.7.2.6. Доступ к внутренним объектам](https://python-all.ru/3.5/library/logging.config.html#access-to-internal-objects)
    - [16.7.2.7. Разрешение импорта и пользовательские импортёры](https://python-all.ru/3.5/library/logging.config.html#import-resolution-and-custom-importers)
  - [16.7.3. Формат файла конфигурации](https://python-all.ru/3.5/library/logging.config.html#configuration-file-format)
- [16.8. `logging.handlers` – Обработчики логирования](https://python-all.ru/3.5/library/logging.handlers.html)

  - [16.8.1. StreamHandler](https://python-all.ru/3.5/library/logging.handlers.html#streamhandler)
  - [16.8.2. FileHandler](https://python-all.ru/3.5/library/logging.handlers.html#filehandler)
  - [16.8.3. NullHandler](https://python-all.ru/3.5/library/logging.handlers.html#nullhandler)
  - [16.8.4. WatchedFileHandler](https://python-all.ru/3.5/library/logging.handlers.html#watchedfilehandler)
  - [16.8.5. BaseRotatingHandler](https://python-all.ru/3.5/library/logging.handlers.html#baserotatinghandler)
  - [16.8.6. RotatingFileHandler](https://python-all.ru/3.5/library/logging.handlers.html#rotatingfilehandler)
  - [16.8.7. TimedRotatingFileHandler](https://python-all.ru/3.5/library/logging.handlers.html#timedrotatingfilehandler)
  - [16.8.8. SocketHandler](https://python-all.ru/3.5/library/logging.handlers.html#sockethandler)
  - [16.8.9. DatagramHandler](https://python-all.ru/3.5/library/logging.handlers.html#datagramhandler)
  - [16.8.10. SysLogHandler](https://python-all.ru/3.5/library/logging.handlers.html#sysloghandler)
  - [16.8.11. NTEventLogHandler](https://python-all.ru/3.5/library/logging.handlers.html#nteventloghandler)
  - [16.8.12. SMTPHandler](https://python-all.ru/3.5/library/logging.handlers.html#smtphandler)
  - [16.8.13. MemoryHandler](https://python-all.ru/3.5/library/logging.handlers.html#memoryhandler)
  - [16.8.14. HTTPHandler](https://python-all.ru/3.5/library/logging.handlers.html#httphandler)
  - [16.8.15. QueueHandler](https://python-all.ru/3.5/library/logging.handlers.html#queuehandler)
  - [16.8.16. QueueListener](https://python-all.ru/3.5/library/logging.handlers.html#queuelistener)
- [16.9. `getpass` – Portable password input](https://python-all.ru/3.5/library/getpass.html)
- [16.10. `curses` – Terminal handling for character-cell displays](https://python-all.ru/3.5/library/curses.html)

  - [16.10.1. Functions](https://python-all.ru/3.5/library/curses.html#functions)
  - [16.10.2. Window Objects](https://python-all.ru/3.5/library/curses.html#window-objects)
  - [16.10.3. Constants](https://python-all.ru/3.5/library/curses.html#constants)
- [16.11. `curses.textpad` – Text input widget for curses programs](https://python-all.ru/3.5/library/curses.html#module-curses.textpad)

  - [16.11.1. Textbox objects](https://python-all.ru/3.5/library/curses.html#textbox-objects)
- [16.12. `curses.ascii` – Utilities for ASCII characters](https://python-all.ru/3.5/library/curses.ascii.html)
- [16.13. `curses.panel` – A panel stack extension for curses](https://python-all.ru/3.5/library/curses.panel.html)

  - [16.13.1. Functions](https://python-all.ru/3.5/library/curses.panel.html#functions)
  - [16.13.2. Panel Objects](https://python-all.ru/3.5/library/curses.panel.html#panel-objects)
- [16.14. `platform` – Access to underlying platform’s identifying data](https://python-all.ru/3.5/library/platform.html)

  - [16.14.1. Cross Platform](https://python-all.ru/3.5/library/platform.html#cross-platform)
  - [16.14.2. Java Platform](https://python-all.ru/3.5/library/platform.html#java-platform)
  - [16.14.3. Windows Platform](https://python-all.ru/3.5/library/platform.html#windows-platform)

    - [16.14.3.1. Win95/98 specific](https://python-all.ru/3.5/library/platform.html#win95-98-specific)
  - [16.14.4. Mac OS Platform](https://python-all.ru/3.5/library/platform.html#mac-os-platform)
  - [16.14.5. Unix Platforms](https://python-all.ru/3.5/library/platform.html#unix-platforms)
- [16.15. `errno` – Standard errno system symbols](https://python-all.ru/3.5/library/errno.html)
- [16.16. `ctypes` – A foreign function library for Python](https://python-all.ru/3.5/library/ctypes.html)

  - [16.16.1. ctypes tutorial](https://python-all.ru/3.5/library/ctypes.html#ctypes-tutorial)

    - [16.16.1.1. Loading dynamic link libraries](https://python-all.ru/3.5/library/ctypes.html#loading-dynamic-link-libraries)
    - [16.16.1.2. Accessing functions from loaded dlls](https://python-all.ru/3.5/library/ctypes.html#accessing-functions-from-loaded-dlls)
    - [16.16.1.3. Calling functions](https://python-all.ru/3.5/library/ctypes.html#calling-functions)
    - [16.16.1.4. Fundamental data types](https://python-all.ru/3.5/library/ctypes.html#fundamental-data-types)
    - [16.16.1.5. Вызов функций, продолжение](https://python-all.ru/3.5/library/ctypes.html#calling-functions-continued)
    - [16.16.1.6. Вызов функций с пользовательскими типами данных](https://python-all.ru/3.5/library/ctypes.html#calling-functions-with-your-own-custom-data-types)
    - [16.16.1.7. Указание типов обязательных аргументов (прототипы функций)](https://python-all.ru/3.5/library/ctypes.html#specifying-the-required-argument-types-function-prototypes)
    - [16.16.1.8. Типы возвращаемых значений](https://python-all.ru/3.5/library/ctypes.html#return-types)
    - [16.16.1.9. Передача указателей (или передача параметров по ссылке)](https://python-all.ru/3.5/library/ctypes.html#passing-pointers-or-passing-parameters-by-reference)
    - [16.16.1.10. Структуры и объединения](https://python-all.ru/3.5/library/ctypes.html#structures-and-unions)
    - [16.16.1.11. Выравнивание структур и объединений и порядок байтов](https://python-all.ru/3.5/library/ctypes.html#structure-union-alignment-and-byte-order)
    - [16.16.1.12. Битовые поля в структурах и объединениях](https://python-all.ru/3.5/library/ctypes.html#bit-fields-in-structures-and-unions)
    - [16.16.1.13. Массивы](https://python-all.ru/3.5/library/ctypes.html#arrays)
    - [16.16.1.14. Указатели](https://python-all.ru/3.5/library/ctypes.html#pointers)
    - [16.16.1.15. Преобразования типов](https://python-all.ru/3.5/library/ctypes.html#type-conversions)
    - [16.16.1.16. Неполные типы](https://python-all.ru/3.5/library/ctypes.html#incomplete-types)
    - [16.16.1.17. Колбэк-функции](https://python-all.ru/3.5/library/ctypes.html#callback-functions)
    - [16.16.1.18. Доступ к значениям, экспортируемым из DLL](https://python-all.ru/3.5/library/ctypes.html#accessing-values-exported-from-dlls)
    - [16.16.1.19. Неожиданности](https://python-all.ru/3.5/library/ctypes.html#surprises)
    - [16.16.1.20. Типы данных переменного размера](https://python-all.ru/3.5/library/ctypes.html#variable-sized-data-types)
  - [16.16.2. Справочник по ctypes](https://python-all.ru/3.5/library/ctypes.html#ctypes-reference)

    - [16.16.2.1. Поиск разделяемых библиотек](https://python-all.ru/3.5/library/ctypes.html#finding-shared-libraries)
    - [16.16.2.2. Загрузка разделяемых библиотек](https://python-all.ru/3.5/library/ctypes.html#loading-shared-libraries)
    - [16.16.2.3. Внешние функции](https://python-all.ru/3.5/library/ctypes.html#foreign-functions)
    - [16.16.2.4. Прототипы функций](https://python-all.ru/3.5/library/ctypes.html#function-prototypes)
    - [16.16.2.5. Вспомогательные функции](https://python-all.ru/3.5/library/ctypes.html#utility-functions)
    - [16.16.2.6. Типы данных](https://python-all.ru/3.5/library/ctypes.html#data-types)
    - [16.16.2.7. Фундаментальные типы данных](https://python-all.ru/3.5/library/ctypes.html#ctypes-fundamental-data-types-2)
    - [16.16.2.8. Структурированные типы данных](https://python-all.ru/3.5/library/ctypes.html#structured-data-types)
    - [16.16.2.9. Массивы и указатели](https://python-all.ru/3.5/library/ctypes.html#arrays-and-pointers)
