Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63672
| From | Dave Angel <davea@davea.name> |
|---|---|
| Subject | Re: Send array back in result from urllib2.urlopen(request, postData) |
| Date | 2014-01-10 18:12 -0500 |
| References | <aae37903-e5ab-41c5-87a7-2e3e78444878@googlegroups.com> <aae37903-e5ab-41c5-87a7-2e3e78444878@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5310.1389395462.18130.python-list@python.org> (permalink) |
On Fri, 10 Jan 2014 12:57:59 -0800 (PST), vanommen.robert@gmail.com wrote: No idea about the php.. > In python when i do > para = result.read() > print para > the output is: > [null,null,null,null,null,"J"] That's a string that just looks like a list. > 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? There are no data fields in a string. > And why is para[5] not "J" but , ? That's character 5 of the string. > How can I change the data back to an array? I've tried with json, but that doesn't change anything. You have to parse it. I don't know what rules you used at the php end, but at a guess, I'd start by stripping the brackets, then splitting by comma. Then iterate through each item looking for special cases. Each item consisting of null gets replaced by None, each item starting with quotes gets them stripped, and perhaps anything else is replaced by float (item). Still questions to ask like whether quoted item can have embedded comma. -- DaveA
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