wangzhibo
2023-07-25 2ccac51ebb1d41c4dd6d2e07f6eb34f75a03210c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
import sys
 
'''
把一行多字,拆成2个字一行;
 
'''
_four_file_name = sys.argv[1]
_four_file_name_out = sys.argv[2]
 
def cut(obj, sec):
    return [obj[i:i+sec] for i in range(0,len(obj),sec)]
 
def write_into_file(words,f_):
    for word in words:
        f_.write(word+"\n")
 
 
with open(_four_file_name_out, 'w', encoding='utf-8') as f_out:
    with open(_four_file_name, 'r', encoding='utf-8-sig') as f:
        for word in f.read().splitlines():
            words = cut(word,2)
            write_into_file(words,f_out)