Hi, How to pack a string variable of length 1 as a char using struct.pack? The following works fine: p = struct.pack('c', b'1')
Whereas this causes an error "char format requires a bytes object of length 1": s = '1' p = struct.pack('c', s) I need to pack a variable rather than a literal. Thanks. -- https://mail.python.org/mailman/listinfo/python-list