0

I have an array list in a txt file like:

[1, 2, 3, 4, 5]

I would like to get this data into an array in my python code. Afterall, when I print it in Python I should see below output:

[1, 2, 3, 4, 5]

(Exactly same with content in txt.)

Is that possible? If yes, how?

1 Answers1

-1

To read the data from your txt file and store it as a list in Python, you can use the following code:


with open('path/to/your/file.txt', 'r') as file: data = file.read()
myList = data.split()