2 Star 3 Fork 2

starsgod/CSDN资源库

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
大学名称数据处理.py 612 Bytes
一键复制 编辑 原始数据 按行查看 历史
starsgod 提交于 2021-04-19 17:04 +08:00 . update 大学名称数据处理.py.
import xlwt
f = open('school_name.txt','r',encoding='utf-8') # 打开文件
datas = f.readlines() # 读取所有行
book = xlwt.Workbook(encoding='utf-8',style_compression=0)
sheet = book.add_sheet('mysheet',cell_overwrite_ok=True)
sheet.write(0,0,'name') # 写入字段名称
length = len(datas) # 统计datas列表元素个数
print(length)
i = 1
j = 0
for line in datas:
sheet.write(i, j, line.strip("\n")) # 注意起始位置为第二行(i=1),第一行为字段名称
i+=1
print("结束")
book.save('school_name.xls') # 保存文件为xls
f.close()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/starsgod/csdn-resource-library.git
git@gitee.com:starsgod/csdn-resource-library.git
starsgod
csdn-resource-library
CSDN资源库
master

搜索帮助