在python

时间:2015-08-05 21:16:24

标签: python json

我是python的初学者,我有一个外部JSON文件,如下所示

[
{
    "Name1": "Schule an der Admiralstraße",
    "Strasse": "Winterstr. 20",
    "PLZ": 28215,
    "Ort": "Bremen",
    "Schulnummer": "002"
},
{
    "Name1": "Schule am Alten Postweg",
    "Strasse": "Alter Postweg 302",
    "PLZ": 28207,
    "Ort": "Bremen",
    "Schulnummer": "003"
},
{
    "Name1": "Schule Am Mönchshof",
    "Strasse": "Hindenburgstr. 33 A",
    "PLZ": 28717,
    "Ort": "Bremen",
    "Schulnummer": "005"
},
{
    "Name1": "Schule An der Gete",
    "Strasse": "An der Gete 103",
    "PLZ": 28211,
    "Ort": "Bremen",
    "Schulnummer": "006"
},
{
    "Name1": "Schule an der Alfred-Faust-Straße",
    "Strasse": "Alfred-Faust-Str. 34",
    "PLZ": 28277,
    "Ort": "Bremen",
    "Schulnummer": "007"
}
]

我正在尝试使用此代码

加载它
import json
jsonfile = 'pathtomyfile'
with open(jsonfile) as data_file:    
    data = json.load(data_file)

但我收到错误: ValueError:无法解码JSON对象   我想我的JSON无论如何都无效,或者我没有正确处理德语字符。我只是想不出来。

0 个答案:

没有答案