我在python中使用numpy数组。我想将数组及其属性打印到txt输出中。我希望文本输出以空行结尾。我该怎么做?
我尝试过:
# Create a text document of the output
with open("demo_numpy.txt","w") as text:
text.write('\n'.join(map(str, [a,shape,size,itemsize,ndim,dtype])) + '\n')
同时还有:
# Create a text document of the output
with open("demo_numpy.txt","w") as text:
text.write('\n'.join(map(str, [a,shape,size,itemsize,ndim,dtype])))
text.write('\n')
然而,当我在GitHub桌面版中打开文件时,仍然会得到文件的最后一行是"dtype"的提示。