Change to.
t = struct.unpack(fmt, str.encode()) # or t = struct.unpack(fmt, bytes(str, 'utf-8'))Don't use
str
as variable as Python use this word.>>> str <class 'str'>