Shortcuts

mmengine.fileio.list_from_file

mmengine.fileio.list_from_file(filename, prefix='', offset=0, max_num=0, encoding='utf-8', file_client_args=None, backend_args=None)[源代码]

Load a text file and parse the content as a list of strings.

list_from_file supports loading a text file which can be storaged in different backends and parsing the content as a list for strings.

参数:
  • filename (str) – Filename.

  • prefix (str) – The prefix to be inserted to the beginning of each item.

  • offset (int) – The offset of lines.

  • max_num (int) – The maximum number of lines to be read, zeros and negatives mean no limitation.

  • encoding (str) – Encoding used to open the file. Defaults to utf-8.

  • file_client_args (dict, optional) – Arguments to instantiate a FileClient. See mmengine.fileio.FileClient for details. Defaults to None. It will be deprecated in future. Please use backend_args instead.

  • backend_args (dict, optional) – Arguments to instantiate the prefix of uri corresponding backend. Defaults to None. New in v0.2.0.

示例

>>> list_from_file('/path/of/your/file')  # disk
['hello', 'world']
>>> list_from_file('s3://path/of/your/file')  # ceph or petrel
['hello', 'world']
返回:

A list of strings.

返回类型:

list[str]

Read the Docs v: latest
Versions
latest
stable
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.1
v0.9.0
v0.8.5
v0.8.4
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.