K
K
KPEBETKA2015-10-15 19:12:23
Python
KPEBETKA, 2015-10-15 19:12:23

What happens inside a struct module function?

There is a code like:

import struct
print struct.unpack('>Q', '12345678')[0]

You need to get exactly the same result of this code, but without using a struct

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KPEBETKA, 2015-10-15
@KPEBETKA

>>> print ord('1') + (ord('2') * 2**8) + (ord('3') * 2**16) + (ord('4') * 2** 24) + (ord('5') * 2**32) + (ord('6') * 2**40) + (ord('7') * 2**48) + (ord('8 ') * 2**56)
4050765991979987505
>>> struct.unpack('Q', '12345678')
(4050765991979987505,)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question