如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/usr/bin/python
# -*- coding:utf8 -*-
import xlwt
import os
workbook = xlwt.Workbook(encoding = 'utf-8' )
booksheet = workbook.add_sheet( 'Sheet 1' , cell_overwrite_ok = True )
DATA = (( '学号' , '姓名' , '年龄' , '性别' , '成绩' ),
( '1001' , 'A' , '11' , '男' , '12' ),
( '1002' , 'B' , '12' , '女' , '22' ),
( '1003' , 'C' , '13' , '女' , '32' ),
( '1004' , 'D' , '14' , '男' , '52' ),
)
for i,row in enumerate (DATA):
for j,col in enumerate (row):
booksheet.write(i,j,col)
print os.getcwd()
|
以上这篇用Python将结果保存为xlsx的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/Blackrosetian/article/details/75332882