Movatterモバイル変換


[0]ホーム

URL:


9951 explained code solutions for 126 technologies


python-numpyHow to load Numpy matrix from text file


import numpy as npmatrix = np.loadtxt('/tmp/matrix.txt')ctrl + c
import numpy as np

loadNumpy module for Python

.loadtxt

load array from text file

/tmp/matrix.txt

path to text file that was previously saved withsavetxt()

matrix

will contain loaded matrix


Usage example

import numpy as npmatrix = np.loadtxt('/tmp/matrix.txt')print(matrix)
output
[[1. 2.] [3. 4.] [5. 6.]]

Join
FreshAll techsGitHubData & Programming blogby Denys Golotiuk

[8]ページ先頭

©2009-2025 Movatter.jp