python 双循环遍历list 变量判断

来源:互联网 发布:微信网络延迟 编辑:程序博客网 时间:2024/06/13 01:46
file1 = 'C:\\Users\\Administrator\\Desktop\\test\\ALL.txt'file2 = 'C:\\Users\\Administrator\\Desktop\\test\\little.txt'ALLlist = []Demondlist = []with open(file1, "r") as f1:    text1 = f1.read()    with open(file2, "r") as f2:        text2 = f2.read()        ALLlist.extend(text1.split())        Demondlist.extend(text2.split())        #print(demond)        for i in ALLlist:            for j in Demondlist:                if j in i:                    print(i)