<分区>
我在用 Python 制作词汇表时遇到了问题。我的代码遍历了一个大约 2.3MB 的文档中的每个单词,并检查该单词是否在字典中,如果不在,它会附加到列表中
问题是,它花了很长时间(我什至还没有完成)。我该如何解决这个问题?
代码:
words = [("_", "hello"), ("hello", "world"), ("world", "."), (".", "_")] # List of a ton of tuples of words
vocab = []
for w in words:
if not w in vocab:
vocab.append(w)