youtube给了我很多想要的直播节目。为此,我使用了google的api,它在json文件中提供信息:
{
"kind": "youtube#channelListResponse",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/wTcrqM2kHwjf7GxOEpSBk_lofRA\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/HhHZCWV2vASrbydwK9ItUgUm0X8\"",
"id": "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
"statistics": {
"viewCount": "19893639729",
"commentCount": "0",
"subscriberCount": "79695778",
"hiddenSubscriberCount": false,
"videoCount": "3707"
}
}
]
}
代码如下:
^{pr2}$但是当我试图用json.loads(),我得到以下错误:
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 2 (char 3)
同时:
print(ascii(json_str))
'{\n {\n "kind": "youtube#channelListResponse",\n "etag": ""XI7nbFXulYBIpL0ayR_gDh3eu1k/wTcrqM2kHwjf7GxOEpSBk_lofRA"",\n "pageInfo": {\n "totalResults": 1,\n "resultsPerPage": 5\n },\n "items": [\n {\n "kind": "youtube#channel",\n "etag": ""XI7nbFXulYBIpL0ayR_gDh3eu1k/HhHZCWV2vASrbydwK9ItUgUm0X8"",\n "id": "UC-lHJZR3Gqxm24_Vd_AJ5Yw",\n "statistics": {\n "viewCount": "19893639729",\n "commentCount": "0",\n "subscriberCount": "79695778",\n "hiddenSubscriberCount": false,\n "videoCount": "3707"\n }\n }\n ]\n}\n'
是什么引起的问题?在
使用下面的代码,我可以打开您的JSON并打印它。将JSON保存到临时json试试这个:
相关问题 更多 >
编程相关推荐