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

Dave Angel davea at davea.name
Thu May 15 09:49:13 EDT 2014


On 05/15/2014 08:34 AM, GuoChao wrote:
> 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 		 	   		
>>>>
>>>>

Please start a new thread, don't just change the subject and hope to 
hijack this existing thread on Fortran.

But you also need a problem statement.  What is it you're having trouble 
with?  Do you have some code that works differently in 3.3 and you want 
to know how to fix it?  If so, show what you've tried, what resulted, 
and what you expected instead.

Please post in text form.  This is a text list, and many people cannot 
see your html at all.  Others see it as improperly wrapped, which 
thoroughly masks what you're trying to do.  Even when I show it as html, 
it doesn't make sense.  Perhaps you're trying to retype the stuff, 
rather than copy/pasting it from your terminal window.

I could comment on individual portions of your query, but hopefully when 
you get one that's better organized, that won't be necessary.


-- 
DaveA



More information about the Python-list mailing list