Документация Python неофициальный перевод

allos.md

187 строк · 21.1 КБ · обычная страница · сырой текст · скачать

1> **Источник:** https://python-all.ru/2.6/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/2.6/library/os.html)1213  - [15.1.1. Параметры процесса](https://python-all.ru/2.6/library/os.html#process-parameters)14  - [15.1.2. Создание файловых объектов](https://python-all.ru/2.6/library/os.html#file-object-creation)15  - [15.1.3. Операции с файловыми дескрипторами](https://python-all.ru/2.6/library/os.html#file-descriptor-operations)1617    - [15.1.3.1. Константы флагов `open()`](https://python-all.ru/2.6/library/os.html#open-flag-constants)18  - [15.1.4. Файлы и каталоги](https://python-all.ru/2.6/library/os.html#files-and-directories)19  - [15.1.5. Управление процессами](https://python-all.ru/2.6/library/os.html#process-management)20  - [15.1.6. Различная системная информация](https://python-all.ru/2.6/library/os.html#miscellaneous-system-information)21  - [15.1.7. Разные функции](https://python-all.ru/2.6/library/os.html#miscellaneous-functions)22- [15.2. `io` – Основные средства для работы с потоками](https://python-all.ru/2.6/library/io.html)2324  - [15.2.1. Интерфейс модуля](https://python-all.ru/2.6/library/io.html#module-interface)25  - [15.2.2. Базовые классы ввода-вывода](https://python-all.ru/2.6/library/io.html#i-o-base-classes)26  - [15.2.3. Низкоуровневый файловый ввод-вывод](https://python-all.ru/2.6/library/io.html#raw-file-i-o)27  - [15.2.4. Буферизованные потоки данных](https://python-all.ru/2.6/library/io.html#buffered-streams)28  - [15.2.5. Текстовый ввод-вывод](https://python-all.ru/2.6/library/io.html#text-i-o)29- [15.3. `time` – Доступ ко времени и преобразования](https://python-all.ru/2.6/library/time.html)30- [15.4. `optparse` – более мощный анализатор параметров командной строки](https://python-all.ru/2.6/library/optparse.html)3132  - [15.4.1. Предыстория](https://python-all.ru/2.6/library/optparse.html#background)3334    - [15.4.1.1. Терминология](https://python-all.ru/2.6/library/optparse.html#terminology)35    - [15.4.1.2. Для чего нужны параметры?](https://python-all.ru/2.6/library/optparse.html#what-are-options-for)36    - [15.4.1.3. Для чего нужны позиционные аргументы?](https://python-all.ru/2.6/library/optparse.html#what-are-positional-arguments-for)37  - [15.4.2. Учебное пособие](https://python-all.ru/2.6/library/optparse.html#tutorial)3839    - [15.4.2.1. Понимание действий параметров](https://python-all.ru/2.6/library/optparse.html#understanding-option-actions)40    - [15.4.2.2. Действие store](https://python-all.ru/2.6/library/optparse.html#the-store-action)41    - [15.4.2.3. Обработка булевых (флаговых) параметров](https://python-all.ru/2.6/library/optparse.html#handling-boolean-flag-options)42    - [15.4.2.4. Другие действия](https://python-all.ru/2.6/library/optparse.html#other-actions)43    - [15.4.2.5. Значения по умолчанию](https://python-all.ru/2.6/library/optparse.html#default-values)44    - [15.4.2.6. Генерация справки](https://python-all.ru/2.6/library/optparse.html#generating-help)45    - [15.4.2.7. Вывод строки версии](https://python-all.ru/2.6/library/optparse.html#printing-a-version-string)46    - [15.4.2.8. Как `optparse` обрабатывает ошибки](https://python-all.ru/2.6/library/optparse.html#how-optparse-handles-errors)47    - [15.4.2.9. Собираем всё вместе](https://python-all.ru/2.6/library/optparse.html#putting-it-all-together)48  - [15.4.3. Справочное руководство](https://python-all.ru/2.6/library/optparse.html#reference-guide)4950    - [15.4.3.1. Создание анализатора](https://python-all.ru/2.6/library/optparse.html#creating-the-parser)51    - [15.4.3.2. Наполнение анализатора](https://python-all.ru/2.6/library/optparse.html#populating-the-parser)52    - [15.4.3.3. Определение параметров](https://python-all.ru/2.6/library/optparse.html#defining-options)53    - [15.4.3.4. Атрибуты параметров](https://python-all.ru/2.6/library/optparse.html#option-attributes)54    - [15.4.3.5. Стандартные действия параметров](https://python-all.ru/2.6/library/optparse.html#standard-option-actions)55    - [15.4.3.6. Стандартные типы параметров](https://python-all.ru/2.6/library/optparse.html#standard-option-types)56    - [15.4.3.7. Разбор аргументов](https://python-all.ru/2.6/library/optparse.html#parsing-arguments)57    - [15.4.3.8. Запросы и управление анализатором параметров](https://python-all.ru/2.6/library/optparse.html#querying-and-manipulating-your-option-parser)58    - [15.4.3.9. Конфликты между параметрами](https://python-all.ru/2.6/library/optparse.html#conflicts-between-options)59    - [15.4.3.10. Очистка](https://python-all.ru/2.6/library/optparse.html#cleanup)60    - [15.4.3.11. Другие методы](https://python-all.ru/2.6/library/optparse.html#other-methods)61  - [15.4.4. Колбэки опций](https://python-all.ru/2.6/library/optparse.html#option-callbacks)6263    - [15.4.4.1. Определение опции с колбэком](https://python-all.ru/2.6/library/optparse.html#defining-a-callback-option)64    - [15.4.4.2. Как вызываются колбэки](https://python-all.ru/2.6/library/optparse.html#how-callbacks-are-called)65    - [15.4.4.3. Возбуждение ошибок в колбэке](https://python-all.ru/2.6/library/optparse.html#raising-errors-in-a-callback)66    - [15.4.4.4. Пример колбэка 1: простой колбэк](https://python-all.ru/2.6/library/optparse.html#callback-example-1-trivial-callback)67    - [15.4.4.5. Пример колбэка 2: проверка порядка опций](https://python-all.ru/2.6/library/optparse.html#callback-example-2-check-option-order)68    - [15.4.4.6. Пример колбэка 3: проверка порядка опций (обобщённая)](https://python-all.ru/2.6/library/optparse.html#callback-example-3-check-option-order-generalized)69    - [15.4.4.7. Пример колбэка 4: проверка произвольного условия](https://python-all.ru/2.6/library/optparse.html#callback-example-4-check-arbitrary-condition)70    - [15.4.4.8. Пример колбэка 5: фиксированные аргументы](https://python-all.ru/2.6/library/optparse.html#callback-example-5-fixed-arguments)71    - [15.4.4.9. Пример колбэка 6: переменное число аргументов](https://python-all.ru/2.6/library/optparse.html#callback-example-6-variable-arguments)72  - [15.4.5. Расширение `optparse`](https://python-all.ru/2.6/library/optparse.html#extending-optparse)7374    - [15.4.5.1. Добавление новых типов](https://python-all.ru/2.6/library/optparse.html#adding-new-types)75    - [15.4.5.2. Добавление новых действий](https://python-all.ru/2.6/library/optparse.html#adding-new-actions)76- [15.5. `getopt` – Парсер параметров командной строки](https://python-all.ru/2.6/library/getopt.html)77- [15.6. `logging` – Средство журналирования для Python](https://python-all.ru/2.6/library/logging.html)7879  - [15.6.1. Учебное пособие по logging](https://python-all.ru/2.6/library/logging.html#logging-tutorial)8081    - [15.6.1.1. Простые примеры](https://python-all.ru/2.6/library/logging.html#simple-examples)82    - [15.6.1.2. Логгеры](https://python-all.ru/2.6/library/logging.html#loggers)83    - [15.6.1.3. Обработчики](https://python-all.ru/2.6/library/logging.html#handlers)84    - [15.6.1.4. Форматировщики](https://python-all.ru/2.6/library/logging.html#formatters)85    - [15.6.1.5. Настройка журналирования](https://python-all.ru/2.6/library/logging.html#configuring-logging)86    - [15.6.1.6. Настройка журналирования для библиотеки](https://python-all.ru/2.6/library/logging.html#configuring-logging-for-a-library)87  - [15.6.2. Уровни журналирования](https://python-all.ru/2.6/library/logging.html#logging-levels)88  - [15.6.3. Полезные обработчики](https://python-all.ru/2.6/library/logging.html#useful-handlers)89  - [15.6.4. Функции уровня модуля](https://python-all.ru/2.6/library/logging.html#module-level-functions)90  - [15.6.5. Объекты логгера](https://python-all.ru/2.6/library/logging.html#logger-objects)91  - [15.6.6. Базовый пример](https://python-all.ru/2.6/library/logging.html#basic-example)92  - [15.6.7. Журналирование в несколько мест назначения](https://python-all.ru/2.6/library/logging.html#logging-to-multiple-destinations)93  - [15.6.8. Исключения, возникающие при журналировании](https://python-all.ru/2.6/library/logging.html#exceptions-raised-during-logging)94  - [15.6.9. Добавление контекстной информации в вывод журнала](https://python-all.ru/2.6/library/logging.html#adding-contextual-information-to-your-logging-output)95  - [15.6.10. Логирование в один файл из нескольких процессов](https://python-all.ru/2.6/library/logging.html#logging-to-a-single-file-from-multiple-processes)96  - [15.6.11. Отправка и получение событий логирования по сети](https://python-all.ru/2.6/library/logging.html#sending-and-receiving-logging-events-across-a-network)97  - [15.6.12. Использование произвольных объектов в качестве сообщений](https://python-all.ru/2.6/library/logging.html#using-arbitrary-objects-as-messages)98  - [15.6.13. Оптимизация](https://python-all.ru/2.6/library/logging.html#optimization)99  - [15.6.14. Объекты-обработчики](https://python-all.ru/2.6/library/logging.html#handler-objects)100101    - [15.6.14.1. StreamHandler](https://python-all.ru/2.6/library/logging.html#streamhandler)102    - [15.6.14.2. FileHandler](https://python-all.ru/2.6/library/logging.html#filehandler)103    - [15.6.14.3. WatchedFileHandler](https://python-all.ru/2.6/library/logging.html#watchedfilehandler)104    - [15.6.14.4. RotatingFileHandler](https://python-all.ru/2.6/library/logging.html#rotatingfilehandler)105    - [15.6.14.5. TimedRotatingFileHandler](https://python-all.ru/2.6/library/logging.html#timedrotatingfilehandler)106    - [15.6.14.6. SocketHandler](https://python-all.ru/2.6/library/logging.html#sockethandler)107    - [15.6.14.7. DatagramHandler](https://python-all.ru/2.6/library/logging.html#datagramhandler)108    - [15.6.14.8. SysLogHandler](https://python-all.ru/2.6/library/logging.html#sysloghandler)109    - [15.6.14.9. NTEventLogHandler](https://python-all.ru/2.6/library/logging.html#nteventloghandler)110    - [15.6.14.10. SMTPHandler](https://python-all.ru/2.6/library/logging.html#smtphandler)111    - [15.6.14.11. MemoryHandler](https://python-all.ru/2.6/library/logging.html#memoryhandler)112    - [15.6.14.12. HTTPHandler](https://python-all.ru/2.6/library/logging.html#httphandler)113  - [15.6.15. Объекты-форматеры](https://python-all.ru/2.6/library/logging.html#formatter-objects)114  - [15.6.16. Объекты-фильтры](https://python-all.ru/2.6/library/logging.html#filter-objects)115  - [15.6.17. Объекты LogRecord](https://python-all.ru/2.6/library/logging.html#logrecord-objects)116  - [15.6.18. Объекты LoggerAdapter](https://python-all.ru/2.6/library/logging.html#loggeradapter-objects)117  - [15.6.19. Потокобезопасность](https://python-all.ru/2.6/library/logging.html#thread-safety)118  - [15.6.20. Конфигурация](https://python-all.ru/2.6/library/logging.html#configuration)119120    - [15.6.20.1. Функции конфигурации](https://python-all.ru/2.6/library/logging.html#configuration-functions)121    - [15.6.20.2. Формат конфигурационного файла](https://python-all.ru/2.6/library/logging.html#configuration-file-format)122    - [15.6.20.3. Пример сервера конфигурации](https://python-all.ru/2.6/library/logging.html#configuration-server-example)123  - [15.6.21. Дополнительные примеры](https://python-all.ru/2.6/library/logging.html#more-examples)124125    - [15.6.21.1. Несколько обработчиков и форматеров](https://python-all.ru/2.6/library/logging.html#multiple-handlers-and-formatters)126    - [15.6.21.2. Использование логирования в нескольких модулях](https://python-all.ru/2.6/library/logging.html#using-logging-in-multiple-modules)127- [15.7. `getpass` – Переносимый ввод пароля](https://python-all.ru/2.6/library/getpass.html)128- [15.8. `curses` – Управление терминалом для символьных дисплеев](https://python-all.ru/2.6/library/curses.html)129130  - [15.8.1. Функции](https://python-all.ru/2.6/library/curses.html#functions)131  - [15.8.2. Объекты окон](https://python-all.ru/2.6/library/curses.html#window-objects)132  - [15.8.3. Константы](https://python-all.ru/2.6/library/curses.html#constants)133- [15.9. `curses.textpad` – Виджет ввода текста для программ curses](https://python-all.ru/2.6/library/curses.html#module-curses.textpad)134135  - [15.9.1. Объекты Textbox](https://python-all.ru/2.6/library/curses.html#textbox-objects)136- [15.10. `curses.wrapper` – Обработчик терминала для программ curses](https://python-all.ru/2.6/library/curses.html#module-curses.wrapper)137- [15.11. `curses.ascii` – Утилиты для работы с ASCII-символами](https://python-all.ru/2.6/library/curses.ascii.html)138- [15.12. `curses.panel` – Расширение стека панелей для curses](https://python-all.ru/2.6/library/curses.panel.html)139140  - [15.12.1. Функции](https://python-all.ru/2.6/library/curses.panel.html#functions)141  - [15.12.2. Объекты панелей](https://python-all.ru/2.6/library/curses.panel.html#panel-objects)142- [15.13. `platform` – Доступ к идентификационным данным базовой платформы](https://python-all.ru/2.6/library/platform.html)143144  - [15.13.1. Кросс-платформенные](https://python-all.ru/2.6/library/platform.html#cross-platform)145  - [15.13.2. Платформа Java](https://python-all.ru/2.6/library/platform.html#java-platform)146  - [15.13.3. Платформа Windows](https://python-all.ru/2.6/library/platform.html#windows-platform)147148    - [15.13.3.1. Специфичное для Win95/98](https://python-all.ru/2.6/library/platform.html#win95-98-specific)149  - [15.13.4. Платформа Mac OS](https://python-all.ru/2.6/library/platform.html#mac-os-platform)150  - [15.13.5. Платформы Unix](https://python-all.ru/2.6/library/platform.html#unix-platforms)151- [15.14. `errno` – Стандартные системные символы errno](https://python-all.ru/2.6/library/errno.html)152- [15.15. `ctypes` – Библиотека для вызова внешних функций в Python](https://python-all.ru/2.6/library/ctypes.html)153154  - [15.15.1. Учебник по ctypes](https://python-all.ru/2.6/library/ctypes.html#ctypes-tutorial)155156    - [15.15.1.1. Загрузка динамически подключаемых библиотек](https://python-all.ru/2.6/library/ctypes.html#loading-dynamic-link-libraries)157    - [15.15.1.2. Доступ к функциям из загруженных DLL](https://python-all.ru/2.6/library/ctypes.html#accessing-functions-from-loaded-dlls)158    - [15.15.1.3. Вызов функций](https://python-all.ru/2.6/library/ctypes.html#calling-functions)159    - [15.15.1.4. Базовые типы данных](https://python-all.ru/2.6/library/ctypes.html#fundamental-data-types)160    - [15.15.1.5. Вызов функций (продолжение)](https://python-all.ru/2.6/library/ctypes.html#calling-functions-continued)161    - [15.15.1.6. Вызов функций с пользовательскими типами данных](https://python-all.ru/2.6/library/ctypes.html#calling-functions-with-your-own-custom-data-types)162    - [15.15.1.7. Указание требуемых типов аргументов (прототипы функций)](https://python-all.ru/2.6/library/ctypes.html#specifying-the-required-argument-types-function-prototypes)163    - [15.15.1.8. Типы возвращаемых значений](https://python-all.ru/2.6/library/ctypes.html#return-types)164    - [15.15.1.9. Передача указателей (или: передача параметров по ссылке)](https://python-all.ru/2.6/library/ctypes.html#passing-pointers-or-passing-parameters-by-reference)165    - [15.15.1.10. Структуры и объединения](https://python-all.ru/2.6/library/ctypes.html#structures-and-unions)166    - [15.15.1.11. Выравнивание структур и объединений и порядок байтов](https://python-all.ru/2.6/library/ctypes.html#structure-union-alignment-and-byte-order)167    - [15.15.1.12. Битовые поля в структурах и объединениях](https://python-all.ru/2.6/library/ctypes.html#bit-fields-in-structures-and-unions)168    - [15.15.1.13. Массивы](https://python-all.ru/2.6/library/ctypes.html#arrays)169    - [15.15.1.14. Указатели](https://python-all.ru/2.6/library/ctypes.html#pointers)170    - [15.15.1.15. Преобразования типов](https://python-all.ru/2.6/library/ctypes.html#type-conversions)171    - [15.15.1.16. Неполные типы](https://python-all.ru/2.6/library/ctypes.html#incomplete-types)172    - [15.15.1.17. Функции обратного вызова](https://python-all.ru/2.6/library/ctypes.html#callback-functions)173    - [15.15.1.18. Доступ к значениям, экспортируемым из DLL](https://python-all.ru/2.6/library/ctypes.html#accessing-values-exported-from-dlls)174    - [15.15.1.19. Сюрпризы](https://python-all.ru/2.6/library/ctypes.html#surprises)175    - [15.15.1.20. Типы данных переменного размера](https://python-all.ru/2.6/library/ctypes.html#variable-sized-data-types)176  - [15.15.2. Справочник по ctypes](https://python-all.ru/2.6/library/ctypes.html#ctypes-reference)177178    - [15.15.2.1. Поиск разделяемых библиотек](https://python-all.ru/2.6/library/ctypes.html#finding-shared-libraries)179    - [15.15.2.2. Загрузка разделяемых библиотек](https://python-all.ru/2.6/library/ctypes.html#loading-shared-libraries)180    - [15.15.2.3. Внешние функции](https://python-all.ru/2.6/library/ctypes.html#foreign-functions)181    - [15.15.2.4. Прототипы функций](https://python-all.ru/2.6/library/ctypes.html#function-prototypes)182    - [15.15.2.5. Вспомогательные функции](https://python-all.ru/2.6/library/ctypes.html#utility-functions)183    - [15.15.2.6. Типы данных](https://python-all.ru/2.6/library/ctypes.html#data-types)184    - [15.15.2.7. Базовые типы данных](https://python-all.ru/2.6/library/ctypes.html#ctypes-fundamental-data-types-2)185    - [15.15.2.8. Структурированные типы данных](https://python-all.ru/2.6/library/ctypes.html#structured-data-types)186    - [15.15.2.9. Массивы и указатели](https://python-all.ru/2.6/library/ctypes.html#arrays-and-pointers)187