numpy savetxt没有添加逗号分隔符 [英] numpy savetxt is not adding comma delimiter
本文介绍了numpy savetxt没有添加逗号分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
numpy savetxt没有添加逗号分隔符
numpy savetxt is not adding comma delimiter
我有一个包含以下内容的数组:
I have an array with the following contents:
3.880631596916139792e-01
6.835074831218364011e-01
4.604322858429276133e-01
3.494236368132551673e-01
7.142120448019100287e-01
2.579415438181463793e-01
8.230159985476581674e-01
7.342531681855216652e-01
3.196536650498674748e-01
7.444435819161493439e-01
我将其保存如下:
np.savetxt('x.train.1.txt',XTraining, delimiter=',')
但是,当我查看txt文件时,没有逗号.
However when I look into the txt file, there is no commas.
推荐答案
我猜默认的用例是存储列表列表,这就是为什么您需要将其视为仅一个列表列表的原因:
I guess the default use case is to store a list of lists, that's why you either need to treat it as list of only one list:
np.savetxt('x.train.1.txt',[XTraining], delimiter=',')
或者用逗号代替换行符(注意:这会在末尾添加逗号)
Or put the comma instead of the newlines (note: this adds a trailing comma)
np.savetxt('x.train.1.txt',XTraining, newline=',')
这篇关于numpy savetxt没有添加逗号分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文