Aug-20-2020, 09:02 PM
I have created in my PYTHON directory a file named movedata containing the following list of numbers 100, -100, 200, -200, 200 with the aim of importing the data into a file called list such that I can sequentially substitute the numbers into a “for” loop from which a serial write sends the individual numbers to /dev/ttyUSB0.
The for loop works if in the python loop I include the line below
list = [100, -100, 200, -200, 200 ]
If I import the data with
with open(‘movedata’,’r’) as f:
m = f.read()
print(m)
I get
100 -100 200 -200, 200
but if make list = [m] I then get
['100 -100 200 -200, 200\n'] and not [100 -100 200 -200, 200]
All my attempts to rid the contents of the brackets [] of the single quotes and \n have been unsuccessful.
The for loop works if in the python loop I include the line below
list = [100, -100, 200, -200, 200 ]
If I import the data with
with open(‘movedata’,’r’) as f:
m = f.read()
print(m)
I get
100 -100 200 -200, 200
but if make list = [m] I then get
['100 -100 200 -200, 200\n'] and not [100 -100 200 -200, 200]
All my attempts to rid the contents of the brackets [] of the single quotes and \n have been unsuccessful.