网络编程
位置:首页>> 网络编程>> Python编程>> Python 保存矩阵为Excel的实现方法

Python 保存矩阵为Excel的实现方法

作者:美酒爱尔兰  发布时间:2022-07-23 07:05:00 

标签:Python,矩阵,Excel

如下所示:


def save(data, path):
 f = xlwt.Workbook() # 创建工作簿
 sheet1 = f.add_sheet(u'sheet1', cell_overwrite_ok=True) # 创建sheet
 [h, l] = data.shape # h为行数,l为列数
 for i in range(h):
   for j in range(l):
     sheet1.write(i, j, data[i, j])
 f.save(path)

代码简单,但是常用!

来源:https://blog.csdn.net/Ling_cmd/article/details/81063794

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com