allos.md
1> **Источник:** https://python-all.ru/3.1/library/allos.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# 15. Общие службы операционной системы89Модули, описанные в этой главе, предоставляют интерфейсы к возможностям операционной системы, доступным (почти) во всех ОС, таким как файлы и часы. Интерфейсы в основном смоделированы по образцу Unix- или C-интерфейсов, но они также доступны и в большинстве других систем. Вот обзор:1011- [15.1. `os` – Разные интерфейсы операционной системы](https://python-all.ru/3.1/library/os.html)1213 - [15.1.1. Имена файлов, аргументы командной строки и переменные окружения](https://python-all.ru/3.1/library/os.html#file-names-command-line-arguments-and-environment-variables)14 - [15.1.2. Параметры процесса](https://python-all.ru/3.1/library/os.html#process-parameters)15 - [15.1.3. Создание файловых объектов](https://python-all.ru/3.1/library/os.html#file-object-creation)16 - [15.1.4. Операции с файловыми дескрипторами](https://python-all.ru/3.1/library/os.html#file-descriptor-operations)1718 - [15.1.4.1. Константы флагов `open()`](https://python-all.ru/3.1/library/os.html#open-flag-constants)19 - [15.1.5. Файлы и каталоги](https://python-all.ru/3.1/library/os.html#files-and-directories)20 - [15.1.6. Управление процессами](https://python-all.ru/3.1/library/os.html#process-management)21 - [15.1.7. Разная системная информация](https://python-all.ru/3.1/library/os.html#miscellaneous-system-information)22 - [15.1.8. Разные функции](https://python-all.ru/3.1/library/os.html#miscellaneous-functions)23- [15.2. `io` – Основные средства для работы с потоками](https://python-all.ru/3.1/library/io.html)2425 - [15.2.1. Обзор](https://python-all.ru/3.1/library/io.html#overview)2627 - [15.2.1.1. Текстовый ввод-вывод](https://python-all.ru/3.1/library/io.html#text-i-o)28 - [15.2.1.2. Двоичный ввод-вывод](https://python-all.ru/3.1/library/io.html#binary-i-o)29 - [15.2.1.3. Сырой I/O](https://python-all.ru/3.1/library/io.html#raw-i-o)30 - [15.2.2. Интерфейс модуля высокого уровня](https://python-all.ru/3.1/library/io.html#high-level-module-interface)3132 - [15.2.2.1. Потоки в памяти](https://python-all.ru/3.1/library/io.html#in-memory-streams)33 - [15.2.3. Иерархия классов](https://python-all.ru/3.1/library/io.html#class-hierarchy)3435 - [15.2.3.1. Базовые классы ввода-вывода](https://python-all.ru/3.1/library/io.html#i-o-base-classes)36 - [15.2.3.2. Сырой файловый I/O](https://python-all.ru/3.1/library/io.html#raw-file-i-o)37 - [15.2.3.3. Буферизованные потоки](https://python-all.ru/3.1/library/io.html#buffered-streams)38 - [15.2.3.4. Текстовый ввод-вывод](https://python-all.ru/3.1/library/io.html#id1)39 - [15.2.4. Продвинутые темы](https://python-all.ru/3.1/library/io.html#advanced-topics)4041 - [15.2.4.1. Производительность](https://python-all.ru/3.1/library/io.html#performance)4243 - [15.2.4.1.1. Двоичный ввод-вывод](https://python-all.ru/3.1/library/io.html#id2)44 - [15.2.4.1.2. Текстовый ввод-вывод](https://python-all.ru/3.1/library/io.html#id3)45 - [15.2.4.2. Многопоточность](https://python-all.ru/3.1/library/io.html#multi-threading)46 - [15.2.4.3. Реентерабельность](https://python-all.ru/3.1/library/io.html#reentrancy)47- [15.3. `time` – Доступ ко времени и преобразования](https://python-all.ru/3.1/library/time.html)48- [15.4. `optparse` – более мощный анализатор параметров командной строки](https://python-all.ru/3.1/library/optparse.html)4950 - [15.4.1. Предыстория](https://python-all.ru/3.1/library/optparse.html#background)5152 - [15.4.1.1. Терминология](https://python-all.ru/3.1/library/optparse.html#terminology)53 - [15.4.1.2. Для чего нужны параметры?](https://python-all.ru/3.1/library/optparse.html#what-are-options-for)54 - [15.4.1.3. Для чего нужны позиционные аргументы?](https://python-all.ru/3.1/library/optparse.html#what-are-positional-arguments-for)55 - [15.4.2. Учебное пособие](https://python-all.ru/3.1/library/optparse.html#tutorial)5657 - [15.4.2.1. Понимание действий параметров](https://python-all.ru/3.1/library/optparse.html#understanding-option-actions)58 - [15.4.2.2. Действие store](https://python-all.ru/3.1/library/optparse.html#the-store-action)59 - [15.4.2.3. Обработка булевых (флаговых) параметров](https://python-all.ru/3.1/library/optparse.html#handling-boolean-flag-options)60 - [15.4.2.4. Другие действия](https://python-all.ru/3.1/library/optparse.html#other-actions)61 - [15.4.2.5. Значения по умолчанию](https://python-all.ru/3.1/library/optparse.html#default-values)62 - [15.4.2.6. Генерация справки](https://python-all.ru/3.1/library/optparse.html#generating-help)6364 - [15.4.2.6.1. Группировка параметров](https://python-all.ru/3.1/library/optparse.html#grouping-options)65 - [15.4.2.7. Вывод строки версии](https://python-all.ru/3.1/library/optparse.html#printing-a-version-string)66 - [15.4.2.8. Как `optparse` обрабатывает ошибки](https://python-all.ru/3.1/library/optparse.html#how-optparse-handles-errors)67 - [15.4.2.9. Собираем всё вместе](https://python-all.ru/3.1/library/optparse.html#putting-it-all-together)68 - [15.4.3. Справочное руководство](https://python-all.ru/3.1/library/optparse.html#reference-guide)6970 - [15.4.3.1. Создание анализатора](https://python-all.ru/3.1/library/optparse.html#creating-the-parser)71 - [15.4.3.2. Наполнение анализатора](https://python-all.ru/3.1/library/optparse.html#populating-the-parser)72 - [15.4.3.3. Определение параметров](https://python-all.ru/3.1/library/optparse.html#defining-options)73 - [15.4.3.4. Атрибуты параметров](https://python-all.ru/3.1/library/optparse.html#option-attributes)74 - [15.4.3.5. Стандартные действия параметров](https://python-all.ru/3.1/library/optparse.html#standard-option-actions)75 - [15.4.3.6. Стандартные типы параметров](https://python-all.ru/3.1/library/optparse.html#standard-option-types)76 - [15.4.3.7. Разбор аргументов](https://python-all.ru/3.1/library/optparse.html#parsing-arguments)77 - [15.4.3.8. Запросы и управление анализатором параметров](https://python-all.ru/3.1/library/optparse.html#querying-and-manipulating-your-option-parser)78 - [15.4.3.9. Конфликты между параметрами](https://python-all.ru/3.1/library/optparse.html#conflicts-between-options)79 - [15.4.3.10. Очистка](https://python-all.ru/3.1/library/optparse.html#cleanup)80 - [15.4.3.11. Другие методы](https://python-all.ru/3.1/library/optparse.html#other-methods)81 - [15.4.4. Колбэки опций](https://python-all.ru/3.1/library/optparse.html#option-callbacks)8283 - [15.4.4.1. Определение опции с колбэком](https://python-all.ru/3.1/library/optparse.html#defining-a-callback-option)84 - [15.4.4.2. Как вызываются колбэки](https://python-all.ru/3.1/library/optparse.html#how-callbacks-are-called)85 - [15.4.4.3. Возбуждение ошибок в колбэке](https://python-all.ru/3.1/library/optparse.html#raising-errors-in-a-callback)86 - [15.4.4.4. Пример колбэка 1: простой колбэк](https://python-all.ru/3.1/library/optparse.html#callback-example-1-trivial-callback)87 - [15.4.4.5. Пример колбэка 2: проверка порядка опций](https://python-all.ru/3.1/library/optparse.html#callback-example-2-check-option-order)88 - [15.4.4.6. Пример колбэка 3: проверка порядка опций (обобщённая)](https://python-all.ru/3.1/library/optparse.html#callback-example-3-check-option-order-generalized)89 - [15.4.4.7. Пример колбэка 4: проверка произвольного условия](https://python-all.ru/3.1/library/optparse.html#callback-example-4-check-arbitrary-condition)90 - [15.4.4.8. Пример колбэка 5: фиксированные аргументы](https://python-all.ru/3.1/library/optparse.html#callback-example-5-fixed-arguments)91 - [15.4.4.9. Пример колбэка 6: переменное число аргументов](https://python-all.ru/3.1/library/optparse.html#callback-example-6-variable-arguments)92 - [15.4.5. Расширение `optparse`](https://python-all.ru/3.1/library/optparse.html#extending-optparse)9394 - [15.4.5.1. Добавление новых типов](https://python-all.ru/3.1/library/optparse.html#adding-new-types)95 - [15.4.5.2. Добавление новых действий](https://python-all.ru/3.1/library/optparse.html#adding-new-actions)96- [15.5. `getopt` – Парсер параметров командной строки](https://python-all.ru/3.1/library/getopt.html)97- [15.6. `logging` – Средство журналирования для Python](https://python-all.ru/3.1/library/logging.html)9899 - [15.6.1. Учебное пособие по logging](https://python-all.ru/3.1/library/logging.html#logging-tutorial)100101 - [15.6.1.1. Простые примеры](https://python-all.ru/3.1/library/logging.html#simple-examples)102 - [15.6.1.2. Логгеры](https://python-all.ru/3.1/library/logging.html#loggers)103 - [15.6.1.3. Обработчики](https://python-all.ru/3.1/library/logging.html#handlers)104 - [15.6.1.4. Форматировщики](https://python-all.ru/3.1/library/logging.html#formatters)105 - [15.6.1.5. Настройка журналирования](https://python-all.ru/3.1/library/logging.html#configuring-logging)106 - [15.6.1.6. Настройка журналирования для библиотеки](https://python-all.ru/3.1/library/logging.html#configuring-logging-for-a-library)107 - [15.6.2. Уровни журналирования](https://python-all.ru/3.1/library/logging.html#logging-levels)108 - [15.6.3. Полезные обработчики](https://python-all.ru/3.1/library/logging.html#module-logging.handlers)109 - [15.6.4. Функции уровня модуля](https://python-all.ru/3.1/library/logging.html#module-level-functions)110 - [15.6.5. Объекты логгера](https://python-all.ru/3.1/library/logging.html#logger-objects)111 - [15.6.6. Базовый пример](https://python-all.ru/3.1/library/logging.html#basic-example)112 - [15.6.7. Журналирование в несколько мест назначения](https://python-all.ru/3.1/library/logging.html#logging-to-multiple-destinations)113 - [15.6.8. Исключения, возникающие при журналировании](https://python-all.ru/3.1/library/logging.html#exceptions-raised-during-logging)114 - [15.6.9. Добавление контекстной информации в вывод журнала](https://python-all.ru/3.1/library/logging.html#adding-contextual-information-to-your-logging-output)115116 - [15.6.9.1. Использование LoggerAdapter для передачи контекстной информации](https://python-all.ru/3.1/library/logging.html#using-loggeradapters-to-impart-contextual-information)117 - [15.6.9.2. Использование фильтров для передачи контекстной информации](https://python-all.ru/3.1/library/logging.html#using-filters-to-impart-contextual-information)118 - [15.6.10. Логирование в один файл из нескольких процессов](https://python-all.ru/3.1/library/logging.html#logging-to-a-single-file-from-multiple-processes)119 - [15.6.11. Отправка и получение событий логирования по сети](https://python-all.ru/3.1/library/logging.html#sending-and-receiving-logging-events-across-a-network)120 - [15.6.12. Использование произвольных объектов в качестве сообщений](https://python-all.ru/3.1/library/logging.html#using-arbitrary-objects-as-messages)121 - [15.6.13. Оптимизация](https://python-all.ru/3.1/library/logging.html#optimization)122 - [15.6.14. Объекты-обработчики](https://python-all.ru/3.1/library/logging.html#handler-objects)123124 - [15.6.14.1. StreamHandler](https://python-all.ru/3.1/library/logging.html#streamhandler)125 - [15.6.14.2. FileHandler](https://python-all.ru/3.1/library/logging.html#filehandler)126 - [15.6.14.3. NullHandler](https://python-all.ru/3.1/library/logging.html#nullhandler)127 - [15.6.14.4. WatchedFileHandler](https://python-all.ru/3.1/library/logging.html#watchedfilehandler)128 - [15.6.14.5. RotatingFileHandler](https://python-all.ru/3.1/library/logging.html#rotatingfilehandler)129 - [15.6.14.6. TimedRotatingFileHandler](https://python-all.ru/3.1/library/logging.html#timedrotatingfilehandler)130 - [15.6.14.7. SocketHandler](https://python-all.ru/3.1/library/logging.html#sockethandler)131 - [15.6.14.8. DatagramHandler](https://python-all.ru/3.1/library/logging.html#datagramhandler)132 - [15.6.14.9. SysLogHandler](https://python-all.ru/3.1/library/logging.html#sysloghandler)133 - [15.6.14.10. NTEventLogHandler](https://python-all.ru/3.1/library/logging.html#nteventloghandler)134 - [15.6.14.11. SMTPHandler](https://python-all.ru/3.1/library/logging.html#smtphandler)135 - [15.6.14.12. MemoryHandler](https://python-all.ru/3.1/library/logging.html#memoryhandler)136 - [15.6.14.13. HTTPHandler](https://python-all.ru/3.1/library/logging.html#httphandler)137 - [15.6.15. Объекты-форматеры](https://python-all.ru/3.1/library/logging.html#formatter-objects)138 - [15.6.16. Объекты-фильтры](https://python-all.ru/3.1/library/logging.html#filter-objects)139 - [15.6.17. Объекты LogRecord](https://python-all.ru/3.1/library/logging.html#logrecord-objects)140 - [15.6.18. Объекты LoggerAdapter](https://python-all.ru/3.1/library/logging.html#loggeradapter-objects)141 - [15.6.19. Потокобезопасность](https://python-all.ru/3.1/library/logging.html#thread-safety)142 - [15.6.20. Конфигурация](https://python-all.ru/3.1/library/logging.html#configuration)143144 - [15.6.20.1. Функции конфигурации](https://python-all.ru/3.1/library/logging.html#configuration-functions)145 - [15.6.20.2. Формат конфигурационного файла](https://python-all.ru/3.1/library/logging.html#configuration-file-format)146 - [15.6.20.3. Пример сервера конфигурации](https://python-all.ru/3.1/library/logging.html#configuration-server-example)147 - [15.6.21. Дополнительные примеры](https://python-all.ru/3.1/library/logging.html#more-examples)148149 - [15.6.21.1. Несколько обработчиков и форматеров](https://python-all.ru/3.1/library/logging.html#multiple-handlers-and-formatters)150 - [15.6.21.2. Использование логирования в нескольких модулях](https://python-all.ru/3.1/library/logging.html#using-logging-in-multiple-modules)151- [15.7. `getpass` – Переносимый ввод пароля](https://python-all.ru/3.1/library/getpass.html)152- [15.8. `curses` – Управление терминалом для символьных дисплеев](https://python-all.ru/3.1/library/curses.html)153154 - [15.8.1. Функции](https://python-all.ru/3.1/library/curses.html#functions)155 - [15.8.2. Объекты окон](https://python-all.ru/3.1/library/curses.html#window-objects)156 - [15.8.3. Константы](https://python-all.ru/3.1/library/curses.html#constants)157- [15.9. `curses.textpad` – Виджет ввода текста для программ curses](https://python-all.ru/3.1/library/curses.html#module-curses.textpad)158159 - [15.9.1. Объекты Textbox](https://python-all.ru/3.1/library/curses.html#textbox-objects)160- [15.10. `curses.wrapper` – Обработчик терминала для программ curses](https://python-all.ru/3.1/library/curses.html#module-curses.wrapper)161- [15.11. `curses.ascii` – Утилиты для работы с ASCII-символами](https://python-all.ru/3.1/library/curses.ascii.html)162- [15.12. `curses.panel` – Расширение стека панелей для curses](https://python-all.ru/3.1/library/curses.panel.html)163164 - [15.12.1. Функции](https://python-all.ru/3.1/library/curses.panel.html#functions)165 - [15.12.2. Объекты панелей](https://python-all.ru/3.1/library/curses.panel.html#panel-objects)166- [15.13. `platform` – Доступ к идентификационным данным базовой платформы](https://python-all.ru/3.1/library/platform.html)167168 - [15.13.1. Кросс-платформенные](https://python-all.ru/3.1/library/platform.html#cross-platform)169 - [15.13.2. Платформа Java](https://python-all.ru/3.1/library/platform.html#java-platform)170 - [15.13.3. Платформа Windows](https://python-all.ru/3.1/library/platform.html#windows-platform)171172 - [15.13.3.1. Специфичное для Win95/98](https://python-all.ru/3.1/library/platform.html#win95-98-specific)173 - [15.13.4. Платформа Mac OS](https://python-all.ru/3.1/library/platform.html#mac-os-platform)174 - [15.13.5. Платформы Unix](https://python-all.ru/3.1/library/platform.html#unix-platforms)175- [15.14. `errno` – Стандартные системные символы errno](https://python-all.ru/3.1/library/errno.html)176- [15.15. `ctypes` – Библиотека для вызова внешних функций в Python](https://python-all.ru/3.1/library/ctypes.html)177178 - [15.15.1. Учебник по ctypes](https://python-all.ru/3.1/library/ctypes.html#ctypes-tutorial)179180 - [15.15.1.1. Загрузка динамически подключаемых библиотек](https://python-all.ru/3.1/library/ctypes.html#loading-dynamic-link-libraries)181 - [15.15.1.2. Доступ к функциям из загруженных DLL](https://python-all.ru/3.1/library/ctypes.html#accessing-functions-from-loaded-dlls)182 - [15.15.1.3. Вызов функций](https://python-all.ru/3.1/library/ctypes.html#calling-functions)183 - [15.15.1.4. Базовые типы данных](https://python-all.ru/3.1/library/ctypes.html#fundamental-data-types)184 - [15.15.1.5. Вызов функций (продолжение)](https://python-all.ru/3.1/library/ctypes.html#calling-functions-continued)185 - [15.15.1.6. Вызов функций с пользовательскими типами данных](https://python-all.ru/3.1/library/ctypes.html#calling-functions-with-your-own-custom-data-types)186 - [15.15.1.7. Указание требуемых типов аргументов (прототипы функций)](https://python-all.ru/3.1/library/ctypes.html#specifying-the-required-argument-types-function-prototypes)187 - [15.15.1.8. Типы возвращаемых значений](https://python-all.ru/3.1/library/ctypes.html#return-types)188 - [15.15.1.9. Передача указателей (или: передача параметров по ссылке)](https://python-all.ru/3.1/library/ctypes.html#passing-pointers-or-passing-parameters-by-reference)189 - [15.15.1.10. Структуры и объединения](https://python-all.ru/3.1/library/ctypes.html#structures-and-unions)190 - [15.15.1.11. Выравнивание структур и объединений и порядок байтов](https://python-all.ru/3.1/library/ctypes.html#structure-union-alignment-and-byte-order)191 - [15.15.1.12. Битовые поля в структурах и объединениях](https://python-all.ru/3.1/library/ctypes.html#bit-fields-in-structures-and-unions)192 - [15.15.1.13. Массивы](https://python-all.ru/3.1/library/ctypes.html#arrays)193 - [15.15.1.14. Указатели](https://python-all.ru/3.1/library/ctypes.html#pointers)194 - [15.15.1.15. Преобразования типов](https://python-all.ru/3.1/library/ctypes.html#type-conversions)195 - [15.15.1.16. Неполные типы](https://python-all.ru/3.1/library/ctypes.html#incomplete-types)196 - [15.15.1.17. Функции обратного вызова](https://python-all.ru/3.1/library/ctypes.html#callback-functions)197 - [15.15.1.18. Доступ к значениям, экспортируемым из DLL](https://python-all.ru/3.1/library/ctypes.html#accessing-values-exported-from-dlls)198 - [15.15.1.19. Сюрпризы](https://python-all.ru/3.1/library/ctypes.html#surprises)199 - [15.15.1.20. Типы данных переменного размера](https://python-all.ru/3.1/library/ctypes.html#variable-sized-data-types)200 - [15.15.2. Справочник по ctypes](https://python-all.ru/3.1/library/ctypes.html#ctypes-reference)201202 - [15.15.2.1. Поиск разделяемых библиотек](https://python-all.ru/3.1/library/ctypes.html#finding-shared-libraries)203 - [15.15.2.2. Загрузка разделяемых библиотек](https://python-all.ru/3.1/library/ctypes.html#loading-shared-libraries)204 - [15.15.2.3. Внешние функции](https://python-all.ru/3.1/library/ctypes.html#foreign-functions)205 - [15.15.2.4. Прототипы функций](https://python-all.ru/3.1/library/ctypes.html#function-prototypes)206 - [15.15.2.5. Вспомогательные функции](https://python-all.ru/3.1/library/ctypes.html#utility-functions)207 - [15.15.2.6. Типы данных](https://python-all.ru/3.1/library/ctypes.html#data-types)208 - [15.15.2.7. Базовые типы данных](https://python-all.ru/3.1/library/ctypes.html#ctypes-fundamental-data-types-2)209 - [15.15.2.8. Структурированные типы данных](https://python-all.ru/3.1/library/ctypes.html#structured-data-types)210 - [15.15.2.9. Массивы и указатели](https://python-all.ru/3.1/library/ctypes.html#arrays-and-pointers)211