mirror of
https://github.com/Vonng/ddia.git
synced 2026-06-22 17:37:04 +08:00
Merge pull request #119 from cclauss/patch-1
Streamline file operations in convert()
This commit is contained in:
commit
ef60741b6b
1 changed files with 1 additions and 3 deletions
|
|
@ -22,9 +22,7 @@ def convert(infile: str, outfile: str, cfg: str):
|
||||||
"""
|
"""
|
||||||
converter = opencc.OpenCC(cfg)
|
converter = opencc.OpenCC(cfg)
|
||||||
with open(infile, "r") as inf, open(outfile, "w+") as outf:
|
with open(infile, "r") as inf, open(outfile, "w+") as outf:
|
||||||
data = inf.readlines()
|
outf.write("\n".join(converter.convert(line) for line in inf))
|
||||||
data = list(map(converter.convert, data))
|
|
||||||
outf.writelines(data)
|
|
||||||
print(f"Convert to {outfile}")
|
print(f"Convert to {outfile}")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue