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

allos.md

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

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