我一直在努力,當我在網址欄中輸入使用API有以下回應:API/JSON值錯誤
{
"resource": "playerdashptshotlog",
"parameters": {
"LeagueID": "00",
"Season": "2014-15",
"SeasonType": "Regular Season",
"PlayerID": 202066,
"TeamID": 0,
"Outcome": null,
"Location": null,
"Month": 0,
"SeasonSegment": null,
"DateFrom": null,
"DateTo": null,
"OpponentTeamID": 0,
"VsConference": null,
"VsDivision": null,
"GameSegment": null,
"Period": 0,
"LastNGames": 0
},
"resultSets": [
我的代碼如下:
import json, requests
github_url = 'http:dsds
parsed_input = json.loads(github_url)
print (parameters.keys())
print (parameters['LeagueID']['Season'])
我得到
Traceback (most recent call last): File "C:\Python34\Scripts\NBA API-JSON.py", line 27, in parsed_input = json.loads(github_url) File "C:\Python34\lib\json__init__.py", line 318, in loads return _default_decoder.decode(s) File "C:\Python34\lib\json\decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Python34\lib\json\decoder.py", line 361, in raw_decode raise ValueError(errmsg("Expecting value", s, err.value)) from None ValueError: Expecting value: line 1 column 1 (char 0)
當我在Python27運行它,我得到這個錯誤:當我使用Python34說錯誤
Traceback (most recent call last): File "C:\Python27\Scripts\NBA API-JSON.py", line 27, in parsed_input = json.loads(github_url) File "C:\Python27\lib\json__init__.py", line 338, in loads return _default_decoder.decode(s) File "C:\Python27\lib\json\decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded
我想弄清楚我做錯了什麼。我試圖用一個例子回答我發現在發現一個問題:
Parsing Multidimensional JSON Array
你不能複製所有的迴應,因爲你粘貼的內容無效JSON,它以開放的結束'[ ' – Victory
大約60頁的價值 –