python创建Excel文件 xlwt

这个功能并不难,但不知道方法的同学也是很苦恼的。由此记录一下


我的环境为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')


你可能感兴趣的:(python,xlwt,Excel,python,excel,python,xlwt)