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)
最近需要使用统计一个目录下的所有文件,使用python比较方便,就整理了一下代码. import os def gci(filepath): files = os.listdir(filepath) for fi in files: fi_d = os.path.join(filepath,fi) if os.path.isdir(fi_d): gci(fi_d) else: str = os.path.join(filepath,fi_d)+'\n' suffix = str[-5:] pri