从文件中读取JSON?
"strings": [{"-name": "city", "#text": "City"}, {"-name": "phone", "#text": "Phone"}, ..., {"-name": "address", "#text": "Address"}]
import jsonfrom pprint import pprintwith open('strings.json') as json_data: d = json.load(json_data) json_data.close() pprint(d)
Traceback (most recent call last): File "/home/.../android/values/manipulate_json.py", line 5, in <module> d = json.loads(json_data) 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()) TypeError: expected string or buffer [Finished in 0.1s with exit code 1]
编辑
json.loads
json.load
Traceback (most recent call last): File "/home/.../android/values/manipulate_json.py", line 5, in <module> d = json.load(json_data) 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 369, in decode raise ValueError(errmsg("Extra data", s, end, len(s))) ValueError: Extra data: line 829 column 1 - line 829 column 2 (char 18476 - 18477) [Finished in 0.1s with exit code 1]
叮当猫咪
梵蒂冈之花
至尊宝的传说
相关分类