Message120960
| Author |
jfinkels |
| Recipients |
jfinkels |
| Date |
2010年11月11日.16:50:01 |
| SpamBayes Score |
0.0015421959 |
| Marked as misclassified |
No |
| Message-id |
<1289494205.74.0.417330108965.issue10390@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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(). |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年11月11日 16:50:05 | jfinkels | set | recipients:
+ jfinkels |
| 2010年11月11日 16:50:05 | jfinkels | set | messageid: <1289494205.74.0.417330108965.issue10390@psf.upfronthosting.co.za> |
| 2010年11月11日 16:50:01 | jfinkels | link | issue10390 messages |
| 2010年11月11日 16:50:01 | jfinkels | create |
|