Created
March 16, 2016 17:01
-
-
Save chouch0u/51ef8e9944257a437aeb to your computer and use it in GitHub Desktop.
将 Eudic 网页版本导出的生词本单词转换为 Anki 可用的格式。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import re | |
import os | |
if os.path.isfile(sys.argv[2]): | |
os.remove(sys.argv[2]) | |
eudic = open(sys.argv[1]) | |
anki = open(sys.argv[2], 'a') | |
lines = [] | |
for i in eudic: | |
lines.append(i.decode('utf-8')) | |
world = [] | |
for i in lines: | |
world.append(i.split("\t")) | |
txt = "" | |
for i in world: | |
meaning = "" | |
for n in range(2, len(i)): | |
meaning = meaning + i[n] | |
meaning = re.sub(",", ";", meaning) | |
txt = i[1] + "," + meaning | |
anki.write(txt.encode('utf-8')) | |
anki.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment