Reputation: 11
I have the same code, I run it on a raspberry and on win7, and I can't have the same result
The code:
with open('file','rb') as fd:
ttt = fd.read(4)
print (ttt)
seed = unpack('>I', fd.read(4))[0]
print str(seed)
On linux I have the good result.
b')M7\xeb'
692926443
But on windows, I have
>M7ù
1401564715
Why this difference ? Why on linux I have more than 4 char ?
Edit: I have finaly find a way to have same result.
import codecs
with codecs.open("G:/InsideReCaptcha-master/enc", mode='rb') as fd:
ttt = fd.read(4)
seed = unpack('>I', ttt)[0]
Not sure all the code is usefull, but it works.
Upvotes: 1
Views: 632
Reputation: 1227
The Linux output is the binary string representation, which is why it is shown as b'[STRING]'. The accented character is shown as an escaped ASCII alternative. The Windows output is the actual string representation. To make them the same, use decode:
print b'a string'.decode('ascii')
Upvotes: 1