Let's say I have this list where val1, etc are all integers such as val1 = 1, val2 = 15, val3 = 240
values = [val1, val2, val3] so now values = [1, 15, 240]
And I store it to a file named values.txt by using write(str(values)) and then I read it like values = read('values.txt')
and then print it it looks like this [1, 15, 240] which is what I would expect.
Now here is where I'm having trouble. How do I convert this string that was stored back into an actual list of integers that I can index each number?
Do I need to store it a different way? I know I could index each element of the list and store each element as a separate file but that isn't really what I want. I'm coding for use in a MicroPython project but testing it first using Python 3.7 in Thonny.
Thanks.
Don
I think I found a solution in the MicroPython forum. Storing the data as binary rather than text. Delete this post if you like. Thanks.
values = [val1, val2, val3] so now values = [1, 15, 240]
And I store it to a file named values.txt by using write(str(values)) and then I read it like values = read('values.txt')
and then print it it looks like this [1, 15, 240] which is what I would expect.
Now here is where I'm having trouble. How do I convert this string that was stored back into an actual list of integers that I can index each number?
Do I need to store it a different way? I know I could index each element of the list and store each element as a separate file but that isn't really what I want. I'm coding for use in a MicroPython project but testing it first using Python 3.7 in Thonny.
Thanks.
Don
I think I found a solution in the MicroPython forum. Storing the data as binary rather than text. Delete this post if you like. Thanks.