struct.unpack: why 's' fmt char convert to bytestring

GuoChao cx63 at outlook.com
Thu May 15 08:34:46 EDT 2014


The Python documentation gives this same example:>>> record = b'raymond   \x32\x12\x08\x01\x08'
>>> name, serialnum, school, gradelevel = unpack('<10sHHb', record)
but get different results as to 's', don't know why this change in Python 3?  need extra work to encode...>>> name
>>> 'raymond   '  # for 2.7>>> name
>>> b'raymond   '  # for 3.3 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140515/8ae000a3/attachment.html>


More information about the Python-list mailing list