虚位以待(AD)
虚位以待(AD)
首页 > 脚本专栏 > python > python实现读Excel写入.txt的方法

python实现读Excel写入.txt的方法
类别:python   作者:码皇   来源:互联网   点击:

下面小编就为大家分享一篇python实现读Excel写入 txt的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

因为今天要用到把Excel中的数据写入到.txt文件中,所以简单的写了个代码:

    import numpy as np import xlrd #打开excel文件 data= xlrd.open_workbook('./sudata/ng.xls')#打开Excel文件读取数据 sh=data.sheet_by_name("Sheet1")##通过工作簿名称获取 print sh.nrows#行数 5820 print sh.ncols#列数 2 n=0 i=0 file=open("ng.txt","w") for n in range(sh.nrows): for i in range(sh.ncols): text=sh.cell_value(n,i).encode('utf-8') file.write(text) file.write('n')

以上这篇python实现读Excel写入.txt的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

  • python jieba分词并统计词频后输出结果到Excel和txt文档方法
  • python 读取txt中每行数据,并且保存到excel中的实例
  • python中使用xlrd、xlwt操作excel表格详解
  • Python读写Excel文件的实例
  • python高手之路python处理excel文件(方法汇总)
  • python使用xlrd模块读写Excel文件的方法
  • python制作爬虫并将抓取结果保存到excel中
  • Python实现读取txt文件并转换为excel的方法示例
相关热词搜索: python 写入txt