Julie,
I've had to work with some binary files with 3 byte data
types. They were generated by an application coded in Business
Basic. Like you I grabbed it as bytes and converted. For clarity's
sake I used powers of 2 instead of hard coding the numbers. 2^8 makes it
pretty obvious why you're multiplying by 256 IMHO. Look out for negative
numbers though. May not be applicable to "number of seconds" but as a
general rule watch for it. Incidentally when I had to read the same data
with VBA I used the same technique to reverse the byte order from Unix to
Windows. Worked just fine.
John Purser
I have opened a file in binary
mode. The 9th,
10th and 11th bytes contain the time in
seconds. In order to
get this value in decimal I did the
following:
timeinsec = bytes[9] * 65536 + bytes[10] * 256 +
bytes{11]
Would someone please advise if there is a better way to
do this?
Thanks,
Julie.
_______________________________________
想即時收到新 email 通知?
下載 Yahoo!
Messenger http://messenger.yahoo.com.hk
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor