No matter what I try, this string is not split.
def funktion():
ser = serial.Serial('COM5',115200)
b = str("Das ist ein Test")
a = str(ser.readline().decode())
b.split(' ')
a.split('s')
print (a)
print (b)
No matter what I try, this string is not split.
def funktion():
ser = serial.Serial('COM5',115200)
b = str("Das ist ein Test")
a = str(ser.readline().decode())
b.split(' ')
a.split('s')
print (a)
print (b)
String aren't mutable, so you have to re-assign those:
b = b.split(' ')
a = a.split('s')
print(a)
print(b)
See more on Immutable vs Mutable types SO question and in that article.
the split
function does not change the string in-place. it returns a new string. you must do tokens = b.split(' '); print(b)
instead.