Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63675
| Date | 2014-01-11 00:23 +0000 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Send array back in result from urllib2.urlopen(request, postData) |
| References | <aae37903-e5ab-41c5-87a7-2e3e78444878@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5312.1389399830.18130.python-list@python.org> (permalink) |
On 2014-01-10 20:57, vanommen.robert@gmail.com wrote: > Hello, > > I have a Raspberry Pi with 10 temperature sensors. I send the data from the sensors and some other values with json encoding and: > > result = urllib2.urlopen(request, postData) > > to a online PHP script wich places the data in a mysql database. > > In the result: > > result.read() > > i am trying to send data back from the PHP to the RPI. I make an array in PHP > > $para[0] = $REGELING_ORG; > $para[1] = $VLVERWL_ORG; > $para[2] = $VLOERVRAAG_ORG; > $para[3] = $TIJDVLOER_ORG; > $para[4] = $SETPOINT_ORG; > > echo $para; > > In python when i do > > para = result.read() > print para > > the output is: > > [null,null,null,null,null,"J"] > > This is correct according to the data in PHP from the mysql. > > when I do > > print para[1] > > the output is: > > n > > the seccond character from the data. Why is this not the seccond datafield? > And why is para[5] not "J" but , ? > > How can I change the data back to an array? I've tried with json, but that doesn't change anything. > [snip] What exactly do you mean by "json doesn't change anything"? I get this: >>> para = '[null,null,null,null,null,"J"]' >>> print para [null,null,null,null,null,"J"] >>> import json >>> print json.loads(para) [None, None, None, None, None, u'J']
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Send array back in result from urllib2.urlopen(request, postData) vanommen.robert@gmail.com - 2014-01-10 12:57 -0800 Re: Send array back in result from urllib2.urlopen(request, postData) John Gordon <gordon@panix.com> - 2014-01-10 22:53 +0000 Re: Send array back in result from urllib2.urlopen(request, postData) Dave Angel <davea@davea.name> - 2014-01-10 18:12 -0500 Re: Send array back in result from urllib2.urlopen(request, postData) Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-10 23:56 +0000 Re: Send array back in result from urllib2.urlopen(request, postData) MRAB <python@mrabarnett.plus.com> - 2014-01-11 00:23 +0000 Re: Send array back in result from urllib2.urlopen(request, postData) vanommen.robert@gmail.com - 2014-01-11 01:31 -0800
csiph-web