版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yrmao9893/article/details/78719308
这个功能并不难,但不知道方法的同学也是很苦恼的。由此记录一下
我的环境为python2.7
首先安装 xlwt
pip install xlwt
然后直接看代码
# -*- coding: utf-8 -*- import xlwt from xlwt import Workbook book = Workbook(encoding='utf-8') sheet1 = book.add_sheet('Sheet 1') sheet1.write(0,0,"我是第一行第一列") sheet1.write(0,1,"我是第一行第二列") sheet1.write(1,0,"我是第2行第一列") sheet1.write(1,1,"我是第2行第二列") # 保存Excel book.save('path/文件名称.xls') book.save('simple.xls')