import os import xlrd import xlwt def writedata(filepath,datas): f=xlwt.Workbook() sheet1=f.add_sheet(u'sheet1',cell_overwrite_ok=True)#创建sheet i=0 for data in datas: sheet1.write(i,1,data) i=i+1 f.save(filepath) def dataDeal(): urlUnit=[] workbook1=xlrd.open_workbook('c:\Users\A\Desktop\数据缺失版本.xlsx') table1=workbook1.sheet_by_index(0) for i in range(0,table1.nrows): u=table1.cell(i,0).value urlUnit.append(u) workbook=xlrd.open_workbook('C:\Users\A\Desktop\待处理数据.xlsx') table=workbook.sheet_by_index(0) for i in range(0,table.nrows): u=table.cell(i,0).value u="https://"+u urlUnit.append(u) #print(urlUnit) # sum=0 # for i in urlUnit: # print(i) # sum+=1 # print(sum) urlUnit=set(urlUnit) new_list=list(urlUnit) writedata("c:\Users\A\Desktop\enddata.xlsx",new_list) if __name__=='__main__': dataDeal()