python实现读Excel写入. txt的方法

  

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

        进口numpy np   excel导入xlrd #打开文件   data=https://www.yisu.com/zixun/xlrd.open_workbook (。/sudata/ng.xls) #打开Excel文件读取数据   sh=data.sheet_by_name (Sheet1) # #通过工作簿名称获取   打印sh.nrows #行数5820   打印sh.ncols #列数2   n=0   我=0   文件=打开(“ng.txt”、“w”)   n的范围(sh.nrows):   因为我在范围(sh.ncols):   文本=sh.cell_value (n,我).encode (utf - 8)   file.write(文本)   file.write (“\ n”)   之前      

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

python实现读Excel写入. txt的方法