数据处理之词匹配

# -*- coding: utf-8 -*-
"""
库内poi是否包含指定搜索词
"""

import codecs

def include(list_a,list_b):
    result = []
    for string in list_a :
        temp = []
        for obj in list_b :
            temp.append(obj)
        result.append(temp)
    return result
if __name__ == "__main__" :
    lista = []
    listb = []
    fa = open(r'a.txt','r')
    for line in fa :
        line = line.strip('\n').decode('utf-8')
        lista.append(line)
    print(lista[-1])
    fa.close()
    fb = open(r'','r')
    for line in fb:
        line = line.strip('\n').decode('gbk')
        listb.append(line)
    print(listb[-1])
    fb.close()
    result = include(lista,set(listb))
    f = codecs.open('','w',encoding = 'gbk')
    for i ,item in enumerate(result):
        print("first for loop:",i,item)
        temp = ''.join(lista[i])
        for it in item :
            print("sec for loop:",i,item)
            temp += '$'
            temp += it
        temp += '\n'
        print(temp)
        f.write(temp)
    f.close()
上一篇:在SpringMVC框架下实现数据的国际化(即数据实现多国文字之间的转换)


下一篇:(Step by Step)How to setup IP Phone Server(VoIP Server) for free.