用python,将有道词典中的生词导入扇贝单词

我试过有道词典和扇贝单词,个人感觉扇贝单词记忆功能非常好用,但是扇贝单词没有pc版,而有道在这方面就做的很好。博主平时都是用有道查生词,那有没有办法将有道词典中的生词导入扇贝中呢?下面的过程看上去很复杂,但实际上只要5分钟!

不得不说扇贝单词还是好用!

一、将有道词典中的单词导出为xml格式

导出以后的结果是这样的,别慌!

二、用python提取xml文件中的代码

下面是GPT写的代码,博主亲测可用!

python 复制代码
import xml.etree.ElementTree as ET

# 解析XML文件
tree = ET.parse('word.xml')
root = tree.getroot()

# 提取英语单词
english_words = []

for item in root.findall('item'):
    word_element = item.find('word')
    if word_element is not None:
        english_words.append(word_element.text.strip())

with open('word.txt', 'w') as file:
    for element in english_words:
        file.write(element + '\n')

# 打印提取的词表长度
print(len(english_words))

提取完的结果是一个txt文件,每一行都是一个单词

三、导入扇贝单词

进入扇贝单词官网,点击上传单词书。

将第二步中txt文件中的内容复制到框中,点击上传,大功告成!

相关推荐
Warson_L9 小时前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅9 小时前
海天线算法的前世今生
python·计算机视觉
韩师傅9 小时前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L9 小时前
LangGraph的MessageState and HumanMessage
python
韩师傅10 小时前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L11 小时前
python的类&继承
python
Warson_L11 小时前
类型标注/type annotation
python
ThreeS13 小时前
手搓MiniVLA全实战教程-一步一步用pytorch解释原理与思路
人工智能·python
金銀銅鐵14 小时前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏