import re import codecs word_a = r'症状.txt' word_b = r'C:UsersAdministrator.SC-201812211013PycharmProjects词表工作代码yiwoquTXTdisease_0903.txt' list_a = [] list_b = [] with codecs.open(word_a,'r','utf8') as f: for line in f: line = line.strip() list_a.append(line) with codecs.open(word_b, 'r', 'utf8') as f: for line in f: line = line.strip() list_b.append(line) for line in list_a: for line_b in list_b: if line == line_b: print(line_b)