As from a list in a text file to make the array?

I need a variable and write to a text file.
points=[(0, 5, 4, 2, 4), (1, 7, 5, 7, 6), (2, 7, 6, 0, 6), (3, 5, 3, 5, 5)]

I do it the following way:

with open('coordinates.txt','w') as file_w:
____for item in range(len(points)):

the type of the variable str points

and then I need to read this file(to pull out of the file contents), but when I get can't convert that content back into the array
April 3rd 20 at 18:27
2 answers
April 3rd 20 at 18:29
Meet serialization. Want, use JSON, want pickle, you want — even msgpack. But of course, pokolesit his own :)
if I want to use json, as I infer from it an array? - gunner commented on April 3rd 20 at 18:32
@gunner, Read the JSON spec. A JSON object can be not only dictionary (as you apparently think), but array, string, numeric, null.

Before the subject, read pickle. It's built into Python "canned", which allows you to save to a file that is a Python object, i.e. when you read it back, then you will have it is this object that you saved. - andy commented on April 3rd 20 at 18:35
@andy, thanks!!! - gunner commented on April 3rd 20 at 18:38
April 3rd 20 at 18:31

Find more questions by tags Python