Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106645
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Jussi Piitulainen <jussi.piitulainen@helsinki.fi> |
| Newsgroups | comp.lang.python |
| Subject | Re: Joining Strings |
| Date | Fri, 08 Apr 2016 08:02:36 +0300 |
| Organization | A noiseless patient Spider |
| Lines | 16 |
| Message-ID | <lf54mbc3d77.fsf@ling.helsinki.fi> (permalink) |
| References | <CAOypoo5YpPLNeobY3uo8o_KjXtfEWcmqffsEUXrqsJ0ACpkBWA@mail.gmail.com> <mailman.51.1459989021.1197.python-list@python.org> <lf5oa9mt3kv.fsf@ling.helsinki.fi> <CAOypoo57s_O4ZysgvqOJeGLPVzmuw85bFK=8AAeDoB=f2ksJbQ@mail.gmail.com> <mailman.53.1460054355.2253.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx02.eternal-september.org; posting-host="305c68510616a2e7ac08bcd2ff1598bd"; logging-data="8436"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192IhlpSb2Ig/638cVDmSuDse9ja1YSFCg=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:QrYlxqqEdwOTypllSlg3tbbC14U= sha1:F3fkdH3ib3YJPj43wQeKNq/+Djg= |
| Xref | csiph.com comp.lang.python:106645 |
Show key headers only | View raw
Emeka writes:
> Thanks it worked when parsed with json.load. However, it needed this
> decode('utf'):
>
> data = json.loads(respData.decode('utf-8'))
So it does. The response data is bytes.
There's also a way to wrap a decoding reader between the response object
and the JSON parser (json.load instead of json.loads):
response = urllib.request.urlopen(command) # a stream of bytes ...
please = codecs.getreader('UTF-8') # ... to characters
result = json.load(please(response))
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Joining Strings Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-04-07 08:01 +0300 Re: Joining Strings Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-04-08 08:02 +0300
csiph-web