使用xlst检查来自另一个文件的数组中是否存在值可以通过以下步骤实现:
import openpyxl
wb1 = openpyxl.load_workbook('file1.xlsx')
sheet1 = wb1.active
wb2 = openpyxl.load_workbook('file2.xlsx')
sheet2 = wb2.active
array_values = []
for row in sheet1.iter_rows(min_row=2, values_only=True):
array_values.append(row[0])
for row in sheet2.iter_rows(min_row=2, values_only=True):
if row[0] in array_values:
print(f"Value {row[0]} exists in the array.")
else:
print(f"Value {row[0]} does not exist in the array.")
以上代码将逐行遍历第二个文件中的值,并检查它们是否存在于第一个文件的数组中。如果存在,则打印相应的存在信息;如果不存在,则打印相应的不存在信息。
这种方法可以使用Python中的openpyxl库来实现,openpyxl是一个功能强大且易于使用的库,用于读取和写入Excel文件。它提供了许多操作Excel文件的方法和属性。
推荐的腾讯云产品:腾讯云COS(对象存储),链接地址:https://cloud.tencent.com/product/cos
领取专属 10元无门槛券
手把手带您无忧上云