我有两个列表,其中包含一些相似的数据,我想比较它们并从父列表中提取最相似的数据

I have two lists with somewhat similar data that I want to compare and pull out the most similar from the parent list

我确定它已经存在于某处,但我找不到它。所以我有两个列表:

sheet_names = ['T307710_TOOLS', 'T307710_CSYS'] #这个是从wb.get_sheet_names()

拉进来的

look_for = ['tools', 'Tools', 'TOOLS', 'setup', 'Setup', 'SETUP'] #these是我要在 sheet 名称

中查找的术语

我想比较两者,然后提取 'T307710_TOOLS' 名称和位置,然后将其存储在变量 tool_sheet 中。

这是我的尝试,我不确定如何比较嵌套 for 循环中的两个列表:

#multiple sheet names, only 1 will specify either TOOLS or SETUP
sheet_names = ['T307710_TOOLS', 'T307710_CSYS'] #wb.get_sheet_names() in my code
#the sheet name I am looking for can be anything from T3771_TOOLS to setupsheet
look_for = ['tools', 'Tools', 'TOOLS', 'setup', 'Setup', 'SETUP']

#me attempting to iterate through the sheet names
for i in sheet_names:
    for j in look_for:
        if j is in i:
            tool_sheet = i
for i in sheet_names:
    for j in look_for:
        if j in i:
            tool_sheet = i

区别在于 for-loop

中的“在”与“在”