這個問題在這里已經有了答案: 如何正確保存和加載 numpy.array() 資料? (4 個回答) 23 小時前關閉。
我有一個二維陣列。我想將此陣列保存在文本檔案中,然后我想使用 python 檢索此陣列。
我的代碼:
np.savetxt('points.txt',final_points)
f=open('points.txt','r')
new_final_points=f.read()
這會將整個陣列保存為 new_final_points 中的字串。我希望它以陣列形式回傳。
uj5u.com熱心網友回復:
您可以使用 numpy 的np.loadtxt方式與np.savetxt
例子:
np.savetxt("points.txt")
array = np.loadtxt("points.txt")
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/457518.html
上一篇:嘗試將檔案名傳輸到其他函式
