好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python之numpy库

python-numpy

csv文件的写入和存取

写入csv文件

CSV (Comma‐Separated Value, 逗号分隔值),是一种常见的文件格式,用来存储批量数据。

写入csv文件

np.savetxt(frame, array, fmt='%.18e', delimiter=None)
? frame : 文件、字符串或产生器,可以是.gz或.bz2的压缩文件
? array : 存入文件的数组
? fmt : 写入文件的格式,例如:%d %.2f %.18e
? delimiter : 分割字符串,默认是任何空格 

示例:

>>> a = np.arange(100).reshape(5,20)>>> np.savetxt('a.csv',a,fmt='%d',delimiter=',') 

查看更多关于python之numpy库的详细内容...

  阅读:39次