user7122465 user7122465 - 4 months ago 32
Python Question

Importing data from arduino to python

I am trying to import data from my arduino to python so that I can then use it in my program but I cannot find how to send the data without importing b'\r\n' as well.
This is an example of what I am currently importing:


# The numbers in the middle are data from four distance sensors


Your Arduino is probably sending the data with b'\r\n' in it.

You can get the numbers out with this regular expression like this:

>>> import re
>>> re.findall('[0-9]+', "b'197,2302,50,198,\r\n'")
['197', '2302', '50', '198']