我正在尝试解析来自下一个谷歌查询的 json 结果:
http://www.google.com/ig/calculator?hl=en&q=1USD=?MXN
结果是这样的:
{lhs: "1 U.S. dollar",rhs: "13.3317335 Mexican pesos",error: "",icc: true}
所以我只是想用这个解码:
import json, urllib2
j=urllib2.urlopen("http://www.google.com/ig/calculator?hl=en&q=1USD=?MXN")
print json.load(j)
但我有这个错误(追溯):
Traceback (most recent call last):
File "/home/rafael/gitSources/PythonConcept/Monpy/negApi.py", line 4, in <module>
print json.load(j)
File "/usr/lib/python2.7/json/__init__.py", line 278, in load
**kw)
File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 1 column 1 (char 1)
[Finished in 0.6s with exit code 1]
我不知道我做错了什么,我只是阅读了很多教程:/
谢谢 :)!