Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106645

Re: Joining Strings

From Jussi Piitulainen <jussi.piitulainen@helsinki.fi>
Newsgroups comp.lang.python
Subject Re: Joining Strings
Date 2016-04-08 08:02 +0300
Organization A noiseless patient Spider
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>

Show all headers | 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 | NextPrevious in thread | Find similar | Unroll thread


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