I have a txt file like this:
input 0 1 2 3 4 5 6 7 0
output 127 191 223 239 247 251 253 254 0
I want to read integers 0 1 2 3 4 5 6 7 0
to a list.
Here is my code:
f=open('data.txt','r')
for line in f:
if 'input' in line:
linestr=line.strip('input')
#linestr=list(map(int,linestr)
print(linestr)
The output is
0 1 2 3 4 5 6 7 0
But when i add "print(linestr[0]+1)"
, it shows error "TypeError: must be str, not int"
Is that means the list I got is still not integer?
How can I use the number as int in this list?
Thx all