如何将Python中的二维数组保存到txt文件中?
- 内容介绍
- 文章标签
- 相关推荐
本文共计209个文字,预计阅读时间需要1分钟。
一种非常繁琐且粗糙的方法,Python属于入门级水平,首先备份一下,如有更好的方法再更新+arrs=[[2, 15, 48, 4, 5], [6, 7, 6, 4, 1], [2, 3, 6, 6, 7], [4, 6, 8, 11, 2]]\narrs=[]\nwith open('testARRS.txt', 'w+') as f:\n for i in range(4):\n join(\)
一个非常繁琐粗暴的方法,python属于入门级水平,就酱先备份一下,如果有更好的方法再更新
arrs=[[2,15,48,4,5],[6,7,6,4,1],[2,3,6,6,7],[4,6,8,11,2]] ARRS = [] f=open('testARRS.txt','w+') for i in range(4): jointsFrame = arrs[i] #每行 ARRS.append(jointsFrame) for Ji in range(5): strNum = str(jointsFrame[Ji]) f.write(strNum) f.write(' ') f.write('\n') f.close()
np.savetxt()方法写入。
以上这篇python保存二维数组到txt文件中的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。
本文共计209个文字,预计阅读时间需要1分钟。
一种非常繁琐且粗糙的方法,Python属于入门级水平,首先备份一下,如有更好的方法再更新+arrs=[[2, 15, 48, 4, 5], [6, 7, 6, 4, 1], [2, 3, 6, 6, 7], [4, 6, 8, 11, 2]]\narrs=[]\nwith open('testARRS.txt', 'w+') as f:\n for i in range(4):\n join(\)
一个非常繁琐粗暴的方法,python属于入门级水平,就酱先备份一下,如果有更好的方法再更新
arrs=[[2,15,48,4,5],[6,7,6,4,1],[2,3,6,6,7],[4,6,8,11,2]] ARRS = [] f=open('testARRS.txt','w+') for i in range(4): jointsFrame = arrs[i] #每行 ARRS.append(jointsFrame) for Ji in range(5): strNum = str(jointsFrame[Ji]) f.write(strNum) f.write(' ') f.write('\n') f.close()
np.savetxt()方法写入。
以上这篇python保存二维数组到txt文件中的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

