查看两个文本相同行
import re import codecs word_a = r'症状.txt' word_b = r'C:\Users\Administrator.SC-201812211013\PycharmProjects\词表工作代码\yiwoqu\TXT\disease_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)