Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下将矩阵的浮动值保存到文本文件中
numpy.savetxt('bool',mat,fmt='%f',delimiter=',')
如何保存布尔矩阵?保存布尔矩阵的 fmt 是什么?
没错,布尔值是整数,所以你总是可以在两者之间。
import numpy as np arr = np.array([True, True, False, False]) np.savetxt("test.txt", arr, fmt="%5i")
这给出了一个文件 1 1 0 0