Skip to main content

简介

将单词批量生成为 Anki 卡片。

当前支持的词典:

使用环境

安装

方式一:通过 pip 安装

$ pip3 install dict2anki

方式二:下载源码

$ git clone https://github.com/qianbinbin/dict2anki.git && cd dict2anki
$ # 或者
$ git clone git@github.com:qianbinbin/dict2anki.git && cd dict2anki
$ # 或者
$ wget https://github.com/qianbinbin/dict2anki/archive/master.zip && unzip master.zip && cd dict2anki-master

使用

一、准备单词文件

以换行分隔,# 开头的行将被忽略,例如 list.txt:

abandon
abbreviate
abduct
abide
abide by sth
abject
abolish
abort
abortion
abound
# this line will be ignored

二、生成

$ # pip 方式
$ dict2anki -i /path/to/list.txt
$ # 源码方式
$ python3 -m dict2anki -i /path/to/list.txt

使用 -i 参数指定输入单词文件,默认生成在当前目录。

生成的卡片文件 cards.txt 是以追加形式写入的,如果单词被放在多个文件中,就可以多次运行脚本以输出到同一 cards.txt

三、导入

1. 新建模板

打开桌面版 Anki,工具 -> 管理笔记模板 -> 添加 -> 问答题,输入名称,例如 单词模板,选中 单词模板,点击右侧 卡片

  • front-template.txt 中的内容复制到 正面模板
  • back-template.txt 中的内容复制到 背面模板
  • styling.txt 中的内容复制到 样式

以上“复制”指完全替换,不是粘贴到原始内容后。

2. 复制媒体文件

collection.media 文件夹中的内容(如果有的话),复制到 Anki 文件夹 对应用户的 collection.media 文件夹下。

3. 导入卡片

创建所需牌组,例如 单词牌组

文件 -> 导入,选择 cards.txt模板 选择刚刚新建的笔记类型 单词模板牌组 选择 单词牌组,勾选 允许在字段中使用 HTML,点击 导入

四、还原为单词文件(类 Unix 系统)

要还原为 第一步 中的单词文件,打开桌面版 Anki,文件 -> 导出...,导出格式选择 纯文本格式的笔记,牌组选择 单词牌组,取消勾选 包含标签包括 HTML 和引用的媒体,并点击 导出,设置文件名,例如 notes.txt,并保存。

再使用以下命令将单词还原到 out.txt 中:

awk -F '\t' '{print $1}' notes.txt >out.txt

Release files for dict2anki 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dict2anki 0.6.1
File Size Uploaded
dict2anki-0.6.1.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dict2anki 0.6.1
File Interpreter ABI Platform
dict2anki-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.5 kB

Release files / dict2anki-0.6.1.tar.gz

Download URL dict2anki-0.6.1.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
253af6713341b64e8b293b8e9c68703913a3480b5caf6c6b3fa43c4ad20e1f3b
BLAKE2b-256 checksum
How to use checksums
d4dfe3735cbc513138c53a11f805be6c57a97e3fbc53a955fa37d19871693b88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.5

Release files / dict2anki-0.6.1-py3-none-any.whl

Download URL dict2anki-0.6.1-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5788dec8510cd895e02e564630aeb68aa94fa972c941e711124b8f7256d448c7
BLAKE2b-256 checksum
How to use checksums
5f47801c86accad584f0dc349f5a9549be2a385db7b9921d7646bffef76bf18c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page