mirror of
https://github.com/open-mmlab/mmocr.git
synced 2025-06-03 21:54:47 +08:00
Make dirs for list_to_file (#235)
Signed-off-by: lizz <lizz@sensetime.com>
This commit is contained in:
parent
b10b6408ef
commit
1e527e77be
@ -1,3 +1,8 @@
|
||||
import os
|
||||
|
||||
import mmcv
|
||||
|
||||
|
||||
def list_to_file(filename, lines):
|
||||
"""Write a list of strings to a text file.
|
||||
|
||||
@ -5,6 +10,7 @@ def list_to_file(filename, lines):
|
||||
filename (str): The output filename. It will be created/overwritten.
|
||||
lines (list(str)): Data to be written.
|
||||
"""
|
||||
mmcv.mkdir_or_exist(os.path.dirname(filename))
|
||||
with open(filename, 'w', encoding='utf-8') as fw:
|
||||
for line in lines:
|
||||
fw.write(f'{line}\n')
|
||||
|
Loading…
x
Reference in New Issue
Block a user