# structTest.py # import sys from struct import * file = '/home/sj/temp/structTest' if sys.platform[:4] == 'java': file += '_jython' else: file += '_cpython' format = 'B' value = 0x80 fout = open(file, 'w') fout.write(pack(format, value)) fout.close() fin = open(file, 'r') result = unpack(format, fin.read(1))[0] fin.close() print "Output value: ", hex(value) print "Input value : ", hex(result) # Results: # # CPython: # Output value: 0x80 # Input value : 0x80 # # Jython: # Output value: 0x80 # Input value : 0xfd