0

I have an array of numbers in python. I saved it using the code below

file = open("A.txt", "w+")
 

for i in range(300):
    content = str(A[i])
    file.write(content)


file.close()

But when I wanted to read it with this code

def readFile(A):
        fileObj = open('A.txt', "r") #opens the file in read mode
        words = fileObj.read().splitlines() #puts the file into an array
        fileObj.close()
        return words

it turned out that I cant use it as a NumPy array again. How to proceed with this task.

Supposing my array is the following one, I would appreciate your tips.

A=vp.array([[1,2],[3,4]])
Sik Sik
  • 123
  • 1
  • 7
  • You can try pickle. https://docs.python.org/3/library/pickle.html – Vicrobot Jan 16 '22 at 15:01
  • Does this answer your question? [How to save and load numpy.array() data properly?](https://stackoverflow.com/questions/28439701/how-to-save-and-load-numpy-array-data-properly) – Michael Szczesny Jan 16 '22 at 15:01

0 Answers0