wangexxx
damn?even better
2021-01-25 12:12

python导出utf-8格式后输出excel文件为空白

  • python
def saveData(datalist,savepath):
    print("save....")
    
    book = xlwt.Workbook(encoding='utf-8')
    sheet = book.add_sheet('豆瓣电影Top250',cell_overwrite_ok = True)
    col = ('电影详情链接',"图片链接","影片中文名","影片外国名","评分","评价数","概况","相关信息")
    for i in range(0,8):
        sheet.write(0,i,col[i])
    for i in range (0,250):
        print("第%d条"%(i+1))
        data = datalist[1]
        for j in range(0,0):
            sheet.write(i+1,j,data[j])
            
    book.save(savepath)
        
if __name__ == '__main__':    #当程序执行时
 
#调用函数
    main()
    print("爬取完毕!")

代码如下,但是导出的excel文件为空白且只有6kb,用python打开显示如下图:

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答