比较两个列表并验证列表值一包含两个python列表

时间:2015-10-16 16:18:32

标签: python mongodb twitter

我有两个列表,并想检查列表中的任何值是否在列表2中有值,列表2(从twitter给出,因此将始终不同),已列出固定然后它是没有修改。然后你会检查列表中的任何值是否有列表2,并为列表中的单词创建一个等级,另外两个出现。

LIST ONE

track_lista = ['iPhone 6',
               'iPhone 5s',
               'iPhone 6 Plus',
               'iPhone 4s',
               'iPhone 5',
               'iPhone 5c',
               'iPhone 4',
               'Zenfone 2 ZE551ML',
               'Zenfone 5 A500CG',
               'Zenfone 2 Deluxe ZE551ML',
               'Zenfone Max ZC550KL',
               'Zenfone C ZC451CG',
               'Zenfone 2 Laser ZE500KL',
               'Zenfone 4',
               'Zenfone 2 ZE550ML',
               'Zenfone 6 A600CG',
               'Zenfone 2 Laser ZE601KL',
               'Zenfone Selfie ZD551KL',
               'Zenfone 2 Laser ZE550KL]

列出两个

myTweet = ['rt @terranoticiasb: sortearemos esse iphone 5s as 18:00 hrs. pra concorrer basta se inscrever no canal http://t.co/ywnycwfx2o boa sorte! ht…', 'gente ninguém conseguiu ai colocar as lentes do snap no iphone 4s? :']

__author__ = 'Lucas'
# -*- coding: utf-8 -*-
from pymongo import MongoClient
from modelos_Celular import track_lista


client = MongoClient('localhost', 27017)
db = client['twitter_db']
collection = db['twitter_collection']

copia_banco = collection.find()

for tweet in copia_banco:
    try:
        myTweet = (tweet['text']).lower()
        print(myTweet)
    except:
    continue

0 个答案:

没有答案