标签: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‘)
标签:work encoding port range pen from des odi utf-8
原文地址:https://www.cnblogs.com/yymhaha/p/9250466.html