我有两个从服务器数据集的一列中选取的列表
Keywords =(('Nike shoes',),('Adidas shoes',),('Levice Jeans',),('adidas jersey',))
Chats = (('Nike shoes have an offer',),('They are at a discount'),
('Nike shoes are the best',),('They have other offers as well',),
('They have introduced new shoes which are awesome',))
两个列表的格式与上面的完全相同
我想要第三个列表,它将存储关键字列表中的所有常用词
o/p - list3 = ('Nike Shoes')
我尝试过各种方法,但发现了一些错误,比如“列表值应该是整数,而不是元组”
你可以这样做:
这会给你和你需要的一样的输出
给定的数据是tuple,因为它们来自DB。因此,您可能需要先更改数据(当然有不同的方法。)
当前数据不需要
keyword[0].lower()
部分,但将所有文本转换为小写进行比较可能会有所帮助相关问题 更多 >
编程相关推荐