遍历Sheet1中除表头外的每一行数据 for row in worksheet1.iterrows(minrow=2, mincol=1, maxcol=15,…
Jump to turn (9)
- 1遍历Sheet1中除表头外的每一行数据 for row in worksheet1.iterrows(minrow=2, mincol=1, maxcol=15
- 2您好,在上述代码中,我不对第11列以后的内容做出更多的要求,我只需要找出第11列到第15列中符合industry1中关键词的行内容,应该如何改写?
- 3请加上第10列,从第10列开始到第15列
- 4请将上述代码缩进
- 5Traceback (most recent call last): File "C:/Users/Administrator/Desktop/python作品
- 6Traceback (most recent call last): File "C:/Users/Administrator/Desktop/python作品
- 7Traceback (most recent call last): File "C:/Users/Administrator/Desktop/python作品
- 8定义元组 industry1 = ('掩膜版','光掩膜版') for row in worksheet1.iterrows(minrow=2, mincol=
- 9请帮我改写上述代码,要求在结果页中,每行前面写出匹配的关键词,例如‘掩膜版’。
- User
遍历Sheet1中除表头外的每一行数据
for row in worksheet1.iter_rows(min_row=2, min_col=1, max_col=15, values_only=True): match_industry = [] # 存储匹配到的行业关键词 # 遍历每个元素,检查是否包含符合条件的关键词 for i, element in enumerate(row[10:]):
# 检查索引是否在元组长度范围内 if i < len(industry1) and isinstance(element, str) and (element in industry1): match_industry.append(industry1[i]) # 将匹配到的关键词添加到列表中 # 如果11-15列都不包含元组industry2的任意一个关键词,并且匹配到了行业关键词
if (str(row[11]) not in industry2) and (str(row[12]) not in industry2) and (str(row[13]) not in industry2) and (str(row[14]) not in industry2) and match_industry: # 在第一列前添加匹配到的行业关键词 row_list = list(row) # row_list[0:0] = match_industry worksheetR.append(row_list) - Assistant