本来一直在用金山词霸,但是发现自己制作出来的txt格式单词本导入金山词霸后汉语意思会自动给我更改,这让我很不爽(因为高频单词考点意思就那一两个,我不需要把所有单词意思都知道),尝试各种方法,but…it didn’t work,遂转向了有道词典。 有道词典导出的单词本是xml文件,如下 如果你要制作自己的单词本就需要单词和汉语意思一个一个的手动插入修改非常麻烦 所以我写了段python代码终于运行通了,快看下面: Tools:pycharm&Notepad++ 你平常积累的单词写成这种形式存在txt文档里 接下来运行下面这段python代码,目的:把上图txt转成第一张图xml文件格式
infopen = open("reading.txt",'r',encoding='utf-8') #要读取的txt文件reading.txt
lines = infopen.readlines()
xml_file = open(('reading1.xml'), 'w') #生成的xml文件
xml_file.write('')
for line in range(len(lines)-1):
if line % 2 == 0:
xml_file.write('')
xml_file.write(' ' + lines[line].strip('\n') + '\n')
line += 1
xml_file.write(' ' + '' + '\n')
xml_file.write(' reading\n') #reading是你单词本的名字,你可以改成自己的
xml_file.write(' 1\n')
xml_file.write('')
xml_file.write('')
然后用Notepad++打开生成的xml文件,在Notepad++中转换编码格式,如下图: 最后在有道词典中导入xml文件就可以了 ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190423125147510.)
|