希望在列表中查找与主列表中的单词不匹配的单词。你知道吗
代码为:
master = ['This', 'is', 'a', 'pond', 'full', 'of', 'good', 'words']
dontfindme = ['po', 'go', 'a']
预期结果是:
['This', 'is', 'full', 'of', 'words']
我们可以做:
list(set(master).difference(set([m for m in master for df in dontfindme if df in m])))
…但它搞砸了秩序。你知道吗
有没有更好的方法使用列表理解?你知道吗
提供:
您可以使用^{} python内置方法。你知道吗
输出:
相关问题 更多 >
编程相关推荐