サマリー
Opens a local or cloud file handle that supports context manager protocol.
構文
AIOFileOpen (path, {mode}, {encoding}, {mime})
パラメーター | 説明 | データ タイプ |
path | The relative path from the current working directory or an absolute path (absolute vsi path for cloud). | 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 | Returns the file handler as an AIOFile 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))