在使用for 语句写入 excel 的时候遇到最终结果无法覆盖前面的值,不知道怎么处理。,用的是xlsxwriter
row=1
for scotters in model2.by_type("IfcFlowTerminal"):
if scotters.ObjectType == 'Single Pole':
for IfcRelContainedInSpatialStructu in scotters.ContainedInStructure:
list4.append(IfcRelContainedInSpatialStructu.RelatingStructure.Name)
for space in model.by_type("IfcSpace"):
if space.Name in list4:
sheet2.write(row,1,str(space.LongName+space.Name))
sheet2.write(row,2,str(scotters.Name))
row+=1
else:
sheet2.write(row,1,str(space.LongName+space.Name))
sheet2.write(row,2,'No Switch in the space')
row+=1
把他放在第一个for语句外面,但是不可以,必须在那个语句下面才能得到相应的值
保留循环的最终结果。,怎么解决嵌套循环的问题,可以覆盖掉前面的值吗?