如何将xls文件的内容写到TXT文件里,是不是编码出错了
#coding:utf8import xlrd
from xlrd import open_workbook
excel=open_workbook(r"201503new.xls")
num=excel.nsheets
mysheet=excel.sheet_by_index(num-1)
print mysheet.nrows,mysheet.ncols
f=open(r"201503new.txt","a")
for i in range(0,mysheet.nrows):
tmp=""
for j in range(0,mysheet.ncols):
if mysheet.cell(i,j).value!=None:
tmp+=str(mysheet.cell(i,j).value)+"\t"
print tmp
f.write(tmp)
这里无法将内容写进TXT文件里
控制台输出的内容下:
text:u'TS201503080001743' number:57107053934.0 text:u'\u6709\u7ebf\u5bbd\u5e26' xldate:42071.70722222222
[此贴子已经被作者于2016-3-19 15:12编辑过]