Understanding struct.pack in python 2.7 and 3.5+
问题 I am attempting to understand; and resolve, why the following happens: $ python >>> import struct >>> list(struct.pack('hh', *(50,50))) ['2', '\x00', '2', '\x00'] >>> exit() $ python3 >>> import struct >>> list(struct.pack('hh', *(50, 50))) [50, 0, 50, 0] I understand that hh stands for 2 shorts. I understand that struct.pack is converting the two integers (shorts) to a c style struct . But why does the output in 2.7 differ so much from 3.5? Unfortunately I am stuck with python 2.7 for right