Why is this string printing as a byte array in the context of a list, printing as expected in a print statement, and the type is of string, not bytearray?
stringList = []
# Comparing a string, and a string decoded from a byte array
theString = "Hello World1"
value = byteArray.decode("utf-8") # byteArray is set externally, but prints correctly below
# Types are the same
print("theString type: " + str(type(theString)))
print("value type: " + str(type(value)))
# Value are displayed the same
print("theString: " + theString)
print("value: " + value)
# Add each to list
stringList.append(theString)
stringList.append(value)
# the value string prints as a byte array
print(stringList)
Output:
theString type: <class 'str'>
value type: <class 'str'>
theString: Hello World1
value: Hello World0
['Hello World1', 'H\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00\x00\x00\x00W\x00\x00\x00o\x00\x00\x00r\x00\x00\x00l\x00\x00\x00d\x00\x00\x000\x00\x00\x00']