When you have a regular string, you pass in another string object as text to split on.
>>> "split this, string, on the, commas".split(",") ['split this', ' string', ' on the', ' commas']But if instead of a string you have a bytes object, this won't work.
>>> b"split this, string, on the, commas".split(",") Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: a bytes-like object is required, not 'str'Your
arduinoString
is a bytes object. So to split it, the argument has to be a bytes object as well. Instead of ","
, use b","
OR convert it to a string and split it as normal.>>> arduinoString = b"split this, string, on the, commas" >>> arduinoString.split(b",") # split directly on the bytes object [b'split this', b' string', b' on the', b' commas'] >>> arduinoString.decode().split(",") # decode to str, then split the str ['split this', ' string', ' on the', ' commas']Note the result of the split is a list of bytes objects,