This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年11月11日 16:50 by jfinkels, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg120960 - (view) | Author: Jeffrey Finkelstein (jfinkels) * | Date: 2010年11月11日 16:50 | |
The following code produces an error:
# APIKEY defined above
r = urllib.request.urlopen('http://api.billboard.com/apisvc/chart/v1/'
'list/spec?api_key={}&format=JSON'
.format(APIKEY))
j = json.load(r)
Specifically, the urlopen() function returns a request object that can be read, the request object returns a bytes object containing JSON, and the json.load() function tries to mix str and bytes objects when using the re module.
json.load() should convert bytes to str. It is reasonable that one should be able to open a url and pass the result directly to json.load().
|
|||
| msg120961 - (view) | Author: Jeffrey Finkelstein (jfinkels) * | Date: 2010年11月11日 16:53 | |
Nevermind. |
|||
| msg229972 - (view) | Author: Martin Panter (martin.panter) * (Python committer) | Date: 2014年10月25日 01:00 | |
See also Issue 10976, discussing passing bytes() strings to json.loads() |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:08 | admin | set | github: 54599 |
| 2014年10月25日 01:00:55 | martin.panter | set | nosy:
+ martin.panter messages: + msg229972 |
| 2010年11月11日 19:40:16 | r.david.murray | set | status: open -> closed stage: resolved |
| 2010年11月11日 16:53:22 | jfinkels | set | resolution: not a bug messages: + msg120961 |
| 2010年11月11日 16:50:02 | jfinkels | create | |