Title how to ndarray matrix output as a string
Randomly generate a 3X3 matrix, how to convert it to a string output?
import numpy as np
a=np.random.randint(1,9,size=9).reshape((3,3))
print(a.__str__())
Print matrix
[[3 4 8]
[5 8 4]
[4 8 3]]
In this case, you can call ndarray method comes with complete
command line input
a.__str__()
Print results
'[[7 3 2]\n [3 8 3]\n [7 2 1]]'