循环一个文本文件和一个Excel文件

我想查看一个文件中是否包含(不等于)Excel文件中的列。

data = pd.read_excel('C:/Users.../excel.xlsx', sep='\t') f=open("list.txt", "r+") for line in f: line = line.rstrip() for vh in data["Column_of_interest"]: vh = vh.rstrip() match = line in vh print (match) break 

结果应该是全部“真实的”,但它只给了我第一个“真”的。

即使没有find匹配,也会中断…所发布的代码将文本文件中的所有行与Excel文件的第一行进行比较,因为它始终在第一行的末尾执行“break”迭代的内在。

 data = pd.read_excel('C:/Users.../excel.xlsx', sep='\t') f=open("list.txt", "r+") for line in f: line = line.rstrip() for vh in data["Column_of_interest"]: vh = vh.rstrip() if line in vh: print True continue