import xlwt import os def write_excel(words,filename): #写入Excel的函数,words是数据,filename是文件名 wb=xlwt.Workbook() sheet=wb.add_sheet('sheet1') attr=['词语','词性','词频'] #第一行:属性行 for col in range(3): sheet.write(0,col,attr[col]) for row in range(1,len(words)+1)