import xlwt
import xlrd
# 每行文本的第一个字节提取
s = []
y = []
f = open('d:/4.txt','r')
line = f.readlines()
for i in line:
date =i.split(',')[0]
data2 = ''.join(e for e in date if e.isalnum())
y.append(data2)
f.close()
f1 = xlwt.Workbook()
sheet1 = f1.add_sheet(u'sheet1',cell_overwrite_ok=True) #创建sheet
# #将数据写入第 i 行,第 j 列
j = 0
for i in y:
sheet1.write(j,0,i) #循环写容入 竖着写
j=j+1
f1.save('d:/text.xls')#保存文件