RIME表转为单行单义表
2019-04-26 本文已影响0人
Ubuntu_2017
RIME 码表正文,直转为「单行单义」表。
# 导入模块
import os
import re
# 获取文件名
file_list = os.listdir(".")
my_list = list(filter(lambda x: re.match('.*txt', x) != None, file_list))
# 文件名赋值
txt_name = my_list[0]
# 写正文
new_table = open('wb98.txt',"a", encoding='utf-16')
rd_dup = open(txt_name,"r", encoding='utf-16')
while True:
dup_line = rd_dup.readline().rstrip()
if dup_line == "":
break
cut_line = dup_line.split('\t')
dup = cut_line[0] + '\t' + cut_line[1] + '\n'
new_table.write(dup)
rd_dup.close()
new_table.close()
print("成功。")