码迷,mamicode.com
首页 > 其他好文 > 详细

将数据写入excel

时间:2018-07-01 16:56:18      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:work   encoding   port   range   pen   from   des   odi   utf-8   

#!/usr/bin/env python
# coding=utf-8

from xlwt import *

# 需要xlwt库的支持
# import xlwt
file = Workbook(encoding=‘utf-8‘)
# 指定file以utf-8的格式打开
table = file.add_sheet(‘data‘)
ldata = []
aa = open(‘C:/Users/12041/Desktop/shenzheng3.txt‘,‘r‘,encoding=‘utf-8‘)
data = [a for a in aa]
# print(data)
for i, p in enumerate(data):
print(i)
print(p)
for j in range(7):
print(j)
# print(p.split(‘ ‘)[j])
table.write(i,j, p.split(‘ ‘)[j])
file.save(‘data.xls‘)

将数据写入excel

标签:work   encoding   port   range   pen   from   des   odi   utf-8   

原文地址:https://www.cnblogs.com/yymhaha/p/9250466.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!