新建excel文件——xlwt库——新建一个最简单的excel表格——并写入数据
Posted 小白龙白龙马
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了新建excel文件——xlwt库——新建一个最简单的excel表格——并写入数据相关的知识,希望对你有一定的参考价值。
参考网址:https://www.jianshu.com/p/fc97dd7e822c
import xlwt #导入模块 workbook = xlwt.Workbook(encoding=\'utf-8\') #创建workbook 对象 worksheet = workbook.add_sheet(\'sheet1\') #创建工作表sheet worksheet.write(0, 0, \'hello\') #往表中写内容,第一各参数 行,第二个参数列,第三个参数内容 workbook.save(\'students.xls\') #保存表为students.xls
import xlwt #导入模块 workbook = xlwt.Workbook(encoding=\'utf-8\') #创建workbook 对象 worksheet = workbook.add_sheet(\'测试\') #创建工作表sheet worksheet.write(0, 0, \'hello\') #往表中写内容,第一各参数 行,第二个参数列,第三个参数内容 worksheet.write(0, 1, \'01中国\') worksheet.write(1, 1, \'10中国\') worksheet.write(1, 0, \'\') workbook.save(\'C:\\\\Users\\\\del\\\\Desktop\\\\students.xls\') #保存表为students.xls
以上是关于新建excel文件——xlwt库——新建一个最简单的excel表格——并写入数据的主要内容,如果未能解决你的问题,请参考以下文章