Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28039
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: issue with struct.unpack |
| Date | 2012-08-28 22:40 -0400 |
| Organization | > Bestiaria Support Staff < |
| References | <2cc8b390-0b7a-4a0f-ac88-113daf65eba5@googlegroups.com> <mailman.3811.1345922216.4697.python-list@python.org> <f8a1ab56-5387-4e3f-b3ef-2f047973f857@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3916.1346208014.4697.python-list@python.org> (permalink) |
On Tue, 28 Aug 2012 15:35:58 -0700 (PDT), 9bizy
<a.m.akingbulu-11@student.lboro.ac.uk> declaimed the following in
gmane.comp.python.general:
>
> I used this documents but they do not explain or provide an example on how to use struct.unpack for sensor data from an external source or even data from a excel sheet.
Why should it?... struct doesn't care WHERE the data came from; it
just takes a /string of bytes/ and interprets the contents as a series
of raw binary fields based upon the format character.
>>> import struct
>>> data = "elevenbytes"
>>> struct.unpack("!B4HH", data)
(101, 27749, 30309, 28258, 31092, 25971)
>>> ndata = [30, 138, 32260, 563, 3238, 23537]
>>> struct.pack("!B4HH", *ndata)
'\x1e\x00\x8a~\x04\x023\x0c\xa6[\xf1'
>>>
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-25 11:34 -0700
Re: issue with struct.unpack Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-25 20:12 +0100
Re: issue with struct.unpack MRAB <python@mrabarnett.plus.com> - 2012-08-25 20:16 +0100
Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 15:35 -0700
Re: issue with struct.unpack MRAB <python@mrabarnett.plus.com> - 2012-08-28 23:53 +0100
Re: issue with struct.unpack Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-28 22:40 -0400
Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 15:35 -0700
Re: issue with struct.unpack Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-25 19:31 -0400
Re: issue with struct.unpack Alexander Blinne <news@blinne.net> - 2012-08-26 14:53 +0200
Re: issue with struct.unpack MRAB <python@mrabarnett.plus.com> - 2012-08-28 23:49 +0100
Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 16:01 -0700
Re: issue with struct.unpack MRAB <python@mrabarnett.plus.com> - 2012-08-29 00:36 +0100
Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 16:55 -0700
Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 16:55 -0700
Re: issue with struct.unpack Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-28 22:31 -0400
csiph-web