I want to save the whole output of test.py in an array. How can I do this?
test.txt
1.0 0.0 3.0
2.0 0.5 0.0
6.0 4.0 2.0
1.0 0.0 3.0
test.py
a = [0,1]
with open('test.txt') as fd:
for n, line in enumerate(fd):
if n in a:
t = numpy.array(line.split())
print(t)
Output:
['1.0' '0.0' '3.0']
['2.0' '0.5' '0.0']
print beyond the loop:
print(t)
Output beyond the loop:
['2.0' '0.5' '0.0']
How can I get something like this?
[['1.0' '0.0' '3.0']
['2.0' '0.5' '0.0']]