Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有 python 模块进行词法分析?(例如给定一个字符串,它会分析它是否是一个有效的英文单词?)提前谢谢!
您将需要收集英语单词列表。在 UNIX 上,您可以使用 /usr/share/dict/words。将单词列表读入 python 并执行以下操作:
for word in my_string.split(): if not word in word_list: print mystring, "is invalid" else print mystring, "is valid"