mirror of
https://github.com/Vonng/ddia.git
synced 2024-12-06 15:20:12 +08:00
Merge pull request #119 from cclauss/patch-1
Streamline file operations in convert()
This commit is contained in:
commit
ef60741b6b
@ -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 New Issue
Block a user