小智 11
你可以非常简单地使用Python中的set和string功能,看看它是如何执行的(过早的优化是万恶之源!):
common_words = frozenset(("if", "but", "and", "the", "when", "use", "to", "for"))
title = "When to use Python for web applications"
title_words = set(title.lower().split())
keywords = title_words.difference(common_words)
print(keywords)
| 归档时间: | 
 | 
| 查看次数: | 3202 次 | 
| 最近记录: |