有没有一种简单的方法可以理解以下内容
words = ["x", "mouse", "looloo", "google", "foo"]
terms = set()
for i in xrange(len(words)):
terms = terms.union([" ".join(words[j:j + len(words) - i]) for j in xrange(len(words))])
return sorted(terms, key=len, reverse=True)
有没有一种简单的方法可以理解以下内容
words = ["x", "mouse", "looloo", "google", "foo"]
terms = set()
for i in xrange(len(words)):
terms = terms.union([" ".join(words[j:j + len(words) - i]) for j in xrange(len(words))])
return sorted(terms, key=len, reverse=True)