AIOFileOpen
Краткая информация
Открывает локальный или облачный дескриптор файла, поддерживающий протокол контекстного управления.
Синтаксис
AIOFileOpen(path, {mode}, {encoding}, {mime})
| Параметр | Объяснение | Тип данных |
|---|---|---|
|
path |
The relative path from the current working directory or an absolute path (absolute |
String |
|
mode |
Specifies the mode that will be used for opening a file.
Примечание:Only read mode honors the encoding parameter. (Значение по умолчанию — 'r') |
String |
|
encoding |
Specifies the encoding that will be used to open a file.
(Значение по умолчанию — 'utf-8') |
String |
|
mime |
The Multipurpose Internet Mail Extensions (MIME) headers. For faster creation and setting of metadata, set MIME headers when creating the file. (Значение по умолчанию — None) |
Dictionary |
Возвращаемое значение
| Тип данных | Объяснение |
|---|---|
|
Object |
Возвращает дескриптор файла как объект |
Пример кода
# For opening a file in the cloud store
with AIOFileOpen(r"C:\data\datacloud.acs\datafile.txt", 'r') as rcsfile:
rcsfile.seek(5)
rcsfile.tell()
print(rcsfile.read(4))
# For opening a local file
with AIOFileOpen(r"C:\data\datafile.txt", 'r') as rcsfile:
rcsfile.seek(5)
rcsfile.tell()
print(rcsfile.read(4))