allos.md
1> **Источник:** https://python-all.ru/3.4/library/allos.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# 16. Универсальные службы операционной системы89Модули, описанные в этой главе, предоставляют интерфейсы к возможностям операционной системы, доступным (почти) во всех ОС, таким как файлы и часы. Интерфейсы в основном смоделированы по образцу Unix- или C-интерфейсов, но они также доступны и в большинстве других систем. Вот обзор:1011- [16.1. `os` – Различные интерфейсы операционной системы](https://python-all.ru/3.4/library/os.html)1213 - [16.1.1. Имена файлов, аргументы командной строки и переменные окружения](https://python-all.ru/3.4/library/os.html#file-names-command-line-arguments-and-environment-variables)14 - [16.1.2. Параметры процесса](https://python-all.ru/3.4/library/os.html#process-parameters)15 - [16.1.3. Создание файловых объектов](https://python-all.ru/3.4/library/os.html#file-object-creation)16 - [16.1.4. Операции с файловыми дескрипторами](https://python-all.ru/3.4/library/os.html#file-descriptor-operations)1718 - [16.1.4.1. Запрос размера терминала](https://python-all.ru/3.4/library/os.html#querying-the-size-of-a-terminal)19 - [16.1.4.2. Наследование файловых дескрипторов](https://python-all.ru/3.4/library/os.html#inheritance-of-file-descriptors)20 - [16.1.5. Файлы и каталоги](https://python-all.ru/3.4/library/os.html#files-and-directories)2122 - [16.1.5.1. Расширенные атрибуты Linux](https://python-all.ru/3.4/library/os.html#linux-extended-attributes)23 - [16.1.6. Управление процессами](https://python-all.ru/3.4/library/os.html#process-management)24 - [16.1.7. Интерфейс к планировщику](https://python-all.ru/3.4/library/os.html#interface-to-the-scheduler)25 - [16.1.8. Разная системная информация](https://python-all.ru/3.4/library/os.html#miscellaneous-system-information)26 - [16.1.9. Прочие функции](https://python-all.ru/3.4/library/os.html#miscellaneous-functions)27- [16.2. `io` – Основные инструменты для работы с потоками данных](https://python-all.ru/3.4/library/io.html)2829 - [16.2.1. Обзор](https://python-all.ru/3.4/library/io.html#overview)3031 - [16.2.1.1. Текстовый ввод-вывод](https://python-all.ru/3.4/library/io.html#text-i-o)32 - [16.2.1.2. Двоичный ввод-вывод](https://python-all.ru/3.4/library/io.html#binary-i-o)33 - [16.2.1.3. Необработанный ввод-вывод](https://python-all.ru/3.4/library/io.html#raw-i-o)34 - [16.2.2. Интерфейс модуля высокого уровня](https://python-all.ru/3.4/library/io.html#high-level-module-interface)3536 - [16.2.2.1. Потоки в памяти](https://python-all.ru/3.4/library/io.html#in-memory-streams)37 - [16.2.3. Иерархия классов](https://python-all.ru/3.4/library/io.html#class-hierarchy)3839 - [16.2.3.1. Базовые классы ввода-вывода](https://python-all.ru/3.4/library/io.html#i-o-base-classes)40 - [16.2.3.2. Сырой файловый ввод-вывод](https://python-all.ru/3.4/library/io.html#raw-file-i-o)41 - [16.2.3.3. Буферизированные потоки данных](https://python-all.ru/3.4/library/io.html#buffered-streams)42 - [16.2.3.4. Текстовый ввод-вывод](https://python-all.ru/3.4/library/io.html#id1)43 - [16.2.4. Производительность](https://python-all.ru/3.4/library/io.html#performance)4445 - [16.2.4.1. Двоичный ввод-вывод](https://python-all.ru/3.4/library/io.html#id2)46 - [16.2.4.2. Текстовый ввод-вывод](https://python-all.ru/3.4/library/io.html#id3)47 - [16.2.4.3. Многопоточность](https://python-all.ru/3.4/library/io.html#multi-threading)48 - [16.2.4.4. Реентерабельность](https://python-all.ru/3.4/library/io.html#reentrancy)49- [16.3. `time` – Доступ ко времени и преобразования](https://python-all.ru/3.4/library/time.html)50- [16.4. `argparse` – Парсер параметров командной строки, аргументов и подкоманд](https://python-all.ru/3.4/library/argparse.html)5152 - [16.4.1. Пример](https://python-all.ru/3.4/library/argparse.html#example)5354 - [16.4.1.1. Создание парсера](https://python-all.ru/3.4/library/argparse.html#creating-a-parser)55 - [16.4.1.2. Добавление аргументов](https://python-all.ru/3.4/library/argparse.html#adding-arguments)56 - [16.4.1.3. Разбор аргументов](https://python-all.ru/3.4/library/argparse.html#parsing-arguments)57 - [16.4.2. Объекты ArgumentParser](https://python-all.ru/3.4/library/argparse.html#argumentparser-objects)5859 - [16.4.2.1. prog](https://python-all.ru/3.4/library/argparse.html#prog)60 - [16.4.2.2. usage](https://python-all.ru/3.4/library/argparse.html#usage)61 - [16.4.2.3. description](https://python-all.ru/3.4/library/argparse.html#description)62 - [16.4.2.4. epilog](https://python-all.ru/3.4/library/argparse.html#epilog)63 - [16.4.2.5. parents](https://python-all.ru/3.4/library/argparse.html#parents)64 - [16.4.2.6. formatter\_class](https://python-all.ru/3.4/library/argparse.html#formatter-class)65 - [16.4.2.7. prefix\_chars](https://python-all.ru/3.4/library/argparse.html#prefix-chars)66 - [16.4.2.8. fromfile\_prefix\_chars](https://python-all.ru/3.4/library/argparse.html#fromfile-prefix-chars)67 - [16.4.2.9. argument\_default](https://python-all.ru/3.4/library/argparse.html#argument-default)68 - [16.4.2.10. conflict\_handler](https://python-all.ru/3.4/library/argparse.html#conflict-handler)69 - [16.4.2.11. add\_help](https://python-all.ru/3.4/library/argparse.html#add-help)70 - [16.4.3. Метод add\_argument()](https://python-all.ru/3.4/library/argparse.html#the-add-argument-method)7172 - [16.4.3.1. Имя или флаги](https://python-all.ru/3.4/library/argparse.html#name-or-flags)73 - [16.4.3.2. действие](https://python-all.ru/3.4/library/argparse.html#action)74 - [16.4.3.3. nargs](https://python-all.ru/3.4/library/argparse.html#nargs)75 - [16.4.3.4. const](https://python-all.ru/3.4/library/argparse.html#const)76 - [16.4.3.5. default](https://python-all.ru/3.4/library/argparse.html#default)77 - [16.4.3.6. type](https://python-all.ru/3.4/library/argparse.html#type)78 - [16.4.3.7. choices](https://python-all.ru/3.4/library/argparse.html#choices)79 - [16.4.3.8. required](https://python-all.ru/3.4/library/argparse.html#required)80 - [16.4.3.9. help](https://python-all.ru/3.4/library/argparse.html#help)81 - [16.4.3.10. metavar](https://python-all.ru/3.4/library/argparse.html#metavar)82 - [16.4.3.11. dest](https://python-all.ru/3.4/library/argparse.html#dest)83 - [16.4.3.12. Классы Action](https://python-all.ru/3.4/library/argparse.html#action-classes)84 - [16.4.4. Метод parse\_args()](https://python-all.ru/3.4/library/argparse.html#the-parse-args-method)8586 - [16.4.4.1. Синтаксис значений параметров](https://python-all.ru/3.4/library/argparse.html#option-value-syntax)87 - [16.4.4.2. Недопустимые аргументы](https://python-all.ru/3.4/library/argparse.html#invalid-arguments)88 - [16.4.4.3. Аргументы, содержащие `-`](https://python-all.ru/3.4/library/argparse.html#arguments-containing)89 - [16.4.4.4. Сокращения аргументов (сопоставление по префиксу)](https://python-all.ru/3.4/library/argparse.html#argument-abbreviations-prefix-matching)90 - [16.4.4.5. За пределами `sys.argv`](https://python-all.ru/3.4/library/argparse.html#beyond-sys-argv)91 - [16.4.4.6. Объект Namespace](https://python-all.ru/3.4/library/argparse.html#the-namespace-object)92 - [16.4.5. Другие утилиты](https://python-all.ru/3.4/library/argparse.html#other-utilities)9394 - [16.4.5.1. Подкоманды](https://python-all.ru/3.4/library/argparse.html#sub-commands)95 - [16.4.5.2. Объекты FileType](https://python-all.ru/3.4/library/argparse.html#filetype-objects)96 - [16.4.5.3. Группы аргументов](https://python-all.ru/3.4/library/argparse.html#argument-groups)97 - [16.4.5.4. Взаимное исключение](https://python-all.ru/3.4/library/argparse.html#mutual-exclusion)98 - [16.4.5.5. Значения парсера по умолчанию](https://python-all.ru/3.4/library/argparse.html#parser-defaults)99 - [16.4.5.6. Вывод справки](https://python-all.ru/3.4/library/argparse.html#printing-help)100 - [16.4.5.7. Частичный разбор](https://python-all.ru/3.4/library/argparse.html#partial-parsing)101 - [16.4.5.8. Настройка разбора файлов](https://python-all.ru/3.4/library/argparse.html#customizing-file-parsing)102 - [16.4.5.9. Методы выхода](https://python-all.ru/3.4/library/argparse.html#exiting-methods)103 - [16.4.6. Обновление кода optparse](https://python-all.ru/3.4/library/argparse.html#upgrading-optparse-code)104- [16.5. `getopt` – Парсер аргументов командной строки в стиле C](https://python-all.ru/3.4/library/getopt.html)105- [16.6. `logging` – Модуль логирования для Python](https://python-all.ru/3.4/library/logging.html)106107 - [16.6.1. Объекты Logger](https://python-all.ru/3.4/library/logging.html#logger-objects)108 - [16.6.2. Уровни логирования](https://python-all.ru/3.4/library/logging.html#logging-levels)109 - [16.6.3. Объекты-обработчики](https://python-all.ru/3.4/library/logging.html#handler-objects)110 - [16.6.4. Объекты-форматтеры](https://python-all.ru/3.4/library/logging.html#formatter-objects)111 - [16.6.5. Объекты-фильтры](https://python-all.ru/3.4/library/logging.html#filter-objects)112 - [16.6.6. Объекты LogRecord](https://python-all.ru/3.4/library/logging.html#logrecord-objects)113 - [16.6.7. Атрибуты LogRecord](https://python-all.ru/3.4/library/logging.html#logrecord-attributes)114 - [16.6.8. Объекты LoggerAdapter](https://python-all.ru/3.4/library/logging.html#loggeradapter-objects)115 - [16.6.9. Потокобезопасность](https://python-all.ru/3.4/library/logging.html#thread-safety)116 - [16.6.10. Функции уровня модуля](https://python-all.ru/3.4/library/logging.html#module-level-functions)117 - [16.6.11. Атрибуты уровня модуля](https://python-all.ru/3.4/library/logging.html#module-level-attributes)118 - [16.6.12. Интеграция с модулем warnings](https://python-all.ru/3.4/library/logging.html#integration-with-the-warnings-module)119- [16.7. `logging.config` – Конфигурация логирования](https://python-all.ru/3.4/library/logging.config.html)120121 - [16.7.1. Функции конфигурации](https://python-all.ru/3.4/library/logging.config.html#configuration-functions)122 - [16.7.2. Схема словаря конфигурации](https://python-all.ru/3.4/library/logging.config.html#configuration-dictionary-schema)123124 - [16.7.2.1. Детали схемы словаря](https://python-all.ru/3.4/library/logging.config.html#dictionary-schema-details)125 - [16.7.2.2. Инкрементальная конфигурация](https://python-all.ru/3.4/library/logging.config.html#incremental-configuration)126 - [16.7.2.3. Связи объектов](https://python-all.ru/3.4/library/logging.config.html#object-connections)127 - [16.7.2.4. Пользовательские объекты](https://python-all.ru/3.4/library/logging.config.html#user-defined-objects)128 - [16.7.2.5. Доступ к внешним объектам](https://python-all.ru/3.4/library/logging.config.html#access-to-external-objects)129 - [16.7.2.6. Доступ к внутренним объектам](https://python-all.ru/3.4/library/logging.config.html#access-to-internal-objects)130 - [16.7.2.7. Разрешение импорта и пользовательские импортёры](https://python-all.ru/3.4/library/logging.config.html#import-resolution-and-custom-importers)131 - [16.7.3. Формат файла конфигурации](https://python-all.ru/3.4/library/logging.config.html#configuration-file-format)132- [16.8. `logging.handlers` – Обработчики логирования](https://python-all.ru/3.4/library/logging.handlers.html)133134 - [16.8.1. StreamHandler](https://python-all.ru/3.4/library/logging.handlers.html#streamhandler)135 - [16.8.2. FileHandler](https://python-all.ru/3.4/library/logging.handlers.html#filehandler)136 - [16.8.3. NullHandler](https://python-all.ru/3.4/library/logging.handlers.html#nullhandler)137 - [16.8.4. WatchedFileHandler](https://python-all.ru/3.4/library/logging.handlers.html#watchedfilehandler)138 - [16.8.5. BaseRotatingHandler](https://python-all.ru/3.4/library/logging.handlers.html#baserotatinghandler)139 - [16.8.6. RotatingFileHandler](https://python-all.ru/3.4/library/logging.handlers.html#rotatingfilehandler)140 - [16.8.7. TimedRotatingFileHandler](https://python-all.ru/3.4/library/logging.handlers.html#timedrotatingfilehandler)141 - [16.8.8. SocketHandler](https://python-all.ru/3.4/library/logging.handlers.html#sockethandler)142 - [16.8.9. DatagramHandler](https://python-all.ru/3.4/library/logging.handlers.html#datagramhandler)143 - [16.8.10. SysLogHandler](https://python-all.ru/3.4/library/logging.handlers.html#sysloghandler)144 - [16.8.11. NTEventLogHandler](https://python-all.ru/3.4/library/logging.handlers.html#nteventloghandler)145 - [16.8.12. SMTPHandler](https://python-all.ru/3.4/library/logging.handlers.html#smtphandler)146 - [16.8.13. MemoryHandler](https://python-all.ru/3.4/library/logging.handlers.html#memoryhandler)147 - [16.8.14. HTTPHandler](https://python-all.ru/3.4/library/logging.handlers.html#httphandler)148 - [16.8.15. QueueHandler](https://python-all.ru/3.4/library/logging.handlers.html#queuehandler)149 - [16.8.16. QueueListener](https://python-all.ru/3.4/library/logging.handlers.html#queuelistener)150- [16.9. `getpass` – Переносимый ввод пароля](https://python-all.ru/3.4/library/getpass.html)151- [16.10. `curses` – Управление терминалом для символьных дисплеев](https://python-all.ru/3.4/library/curses.html)152153 - [16.10.1. Functions](https://python-all.ru/3.4/library/curses.html#functions)154 - [16.10.2. Window Objects](https://python-all.ru/3.4/library/curses.html#window-objects)155 - [16.10.3. Constants](https://python-all.ru/3.4/library/curses.html#constants)156- [16.11. `curses.textpad` – Виджет ввода текста для программ на curses](https://python-all.ru/3.4/library/curses.html#module-curses.textpad)157158 - [16.11.1. Textbox objects](https://python-all.ru/3.4/library/curses.html#textbox-objects)159- [16.12. `curses.ascii` – Утилиты для работы с ASCII-символами](https://python-all.ru/3.4/library/curses.ascii.html)160- [16.13. `curses.panel` – Расширение стека панелей для curses](https://python-all.ru/3.4/library/curses.panel.html)161162 - [16.13.1. Functions](https://python-all.ru/3.4/library/curses.panel.html#functions)163 - [16.13.2. Panel Objects](https://python-all.ru/3.4/library/curses.panel.html#panel-objects)164- [16.14. `platform` – Доступ к идентификационным данным базовой платформы](https://python-all.ru/3.4/library/platform.html)165166 - [16.14.1. Cross Platform](https://python-all.ru/3.4/library/platform.html#cross-platform)167 - [16.14.2. Java Platform](https://python-all.ru/3.4/library/platform.html#java-platform)168 - [16.14.3. Windows Platform](https://python-all.ru/3.4/library/platform.html#windows-platform)169170 - [16.14.3.1. Win95/98 specific](https://python-all.ru/3.4/library/platform.html#win95-98-specific)171 - [16.14.4. Mac OS Platform](https://python-all.ru/3.4/library/platform.html#mac-os-platform)172 - [16.14.5. Unix Platforms](https://python-all.ru/3.4/library/platform.html#unix-platforms)173- [16.15. `errno` – Стандартные системные символы errno](https://python-all.ru/3.4/library/errno.html)174- [16.16. `ctypes` – Библиотека внешних функций для Python](https://python-all.ru/3.4/library/ctypes.html)175176 - [16.16.1. ctypes tutorial](https://python-all.ru/3.4/library/ctypes.html#ctypes-tutorial)177178 - [16.16.1.1. Loading dynamic link libraries](https://python-all.ru/3.4/library/ctypes.html#loading-dynamic-link-libraries)179 - [16.16.1.2. Accessing functions from loaded dlls](https://python-all.ru/3.4/library/ctypes.html#accessing-functions-from-loaded-dlls)180 - [16.16.1.3. Calling functions](https://python-all.ru/3.4/library/ctypes.html#calling-functions)181 - [16.16.1.4. Fundamental data types](https://python-all.ru/3.4/library/ctypes.html#fundamental-data-types)182 - [16.16.1.5. Вызов функций, продолжение](https://python-all.ru/3.4/library/ctypes.html#calling-functions-continued)183 - [16.16.1.6. Вызов функций с пользовательскими типами данных](https://python-all.ru/3.4/library/ctypes.html#calling-functions-with-your-own-custom-data-types)184 - [16.16.1.7. Указание типов обязательных аргументов (прототипы функций)](https://python-all.ru/3.4/library/ctypes.html#specifying-the-required-argument-types-function-prototypes)185 - [16.16.1.8. Типы возвращаемых значений](https://python-all.ru/3.4/library/ctypes.html#return-types)186 - [16.16.1.9. Передача указателей (или передача параметров по ссылке)](https://python-all.ru/3.4/library/ctypes.html#passing-pointers-or-passing-parameters-by-reference)187 - [16.16.1.10. Структуры и объединения](https://python-all.ru/3.4/library/ctypes.html#structures-and-unions)188 - [16.16.1.11. Выравнивание структур и объединений и порядок байтов](https://python-all.ru/3.4/library/ctypes.html#structure-union-alignment-and-byte-order)189 - [16.16.1.12. Битовые поля в структурах и объединениях](https://python-all.ru/3.4/library/ctypes.html#bit-fields-in-structures-and-unions)190 - [16.16.1.13. Массивы](https://python-all.ru/3.4/library/ctypes.html#arrays)191 - [16.16.1.14. Указатели](https://python-all.ru/3.4/library/ctypes.html#pointers)192 - [16.16.1.15. Преобразования типов](https://python-all.ru/3.4/library/ctypes.html#type-conversions)193 - [16.16.1.16. Неполные типы](https://python-all.ru/3.4/library/ctypes.html#incomplete-types)194 - [16.16.1.17. Колбэк-функции](https://python-all.ru/3.4/library/ctypes.html#callback-functions)195 - [16.16.1.18. Доступ к значениям, экспортируемым из DLL](https://python-all.ru/3.4/library/ctypes.html#accessing-values-exported-from-dlls)196 - [16.16.1.19. Неожиданности](https://python-all.ru/3.4/library/ctypes.html#surprises)197 - [16.16.1.20. Типы данных переменного размера](https://python-all.ru/3.4/library/ctypes.html#variable-sized-data-types)198 - [16.16.2. Справочник по ctypes](https://python-all.ru/3.4/library/ctypes.html#ctypes-reference)199200 - [16.16.2.1. Поиск разделяемых библиотек](https://python-all.ru/3.4/library/ctypes.html#finding-shared-libraries)201 - [16.16.2.2. Загрузка разделяемых библиотек](https://python-all.ru/3.4/library/ctypes.html#loading-shared-libraries)202 - [16.16.2.3. Внешние функции](https://python-all.ru/3.4/library/ctypes.html#foreign-functions)203 - [16.16.2.4. Прототипы функций](https://python-all.ru/3.4/library/ctypes.html#function-prototypes)204 - [16.16.2.5. Вспомогательные функции](https://python-all.ru/3.4/library/ctypes.html#utility-functions)205 - [16.16.2.6. Типы данных](https://python-all.ru/3.4/library/ctypes.html#data-types)206 - [16.16.2.7. Фундаментальные типы данных](https://python-all.ru/3.4/library/ctypes.html#ctypes-fundamental-data-types-2)207 - [16.16.2.8. Структурированные типы данных](https://python-all.ru/3.4/library/ctypes.html#structured-data-types)208 - [16.16.2.9. Массивы и указатели](https://python-all.ru/3.4/library/ctypes.html#arrays-and-pointers)209