python中valueerror是什么错误_我对python中的请求做了什么错误:ValueError:期望值:行1列1(char 0)?...

在使用requests从在线数据库获取信息时,遇到ValueError:期待值错误,通常发生在尝试解析无效JSON响应时。问题出现在对API的调用中,尽管尝试了增加sleep()来避免速率限制,但错误仍然存在。错误源可能与编辑过的同一文件的其他代码有关。
摘要由CSDN通过智能技术生成

我甚至不知道该如何提问,因为这似乎需要大量代码才能了解细节。我将讨论运行时的行为,而不是显示代码。在

我使用请求从一个在线数据库获取信息。当我运行for循环遍历我的所有条目时,在前20个条目中的一个(通常是第一个条目,但不一定总是)出现如下错误。列表中的条目都是一样的(只是不同的ID号)。我使用sleep()来确保不会超出速率限制(我尝试将睡眠时间增加到荒谬的等待时间,但仍然得到错误)。真正让我吃惊的是,它确实起了作用,然后就卡住了。。。。是什么原因造成的?在

另外,代码之前还在工作,然后我对同一文件中的其他代码进行了大量编辑,但我认为我没有编辑任何与此相关的内容。在Traceback (most recent call last):

File "C:/Users/Mark/PycharmProjects/Riot_API_Challenger_Stats/Main.py", line 233, in

main()

File "C:/Users/Mark/PycharmProjects/Riot_API_Challenger_Stats/Main.py", line 212, in main

match_histories=get_match_histories(challenger_Ids+master_Ids)

File "C:/Users/Mark/PycharmProjects/Riot_API_Challenger_Stats/Main.py", line 62, in get_match_histories

match_histories[summoner_Ids[i]]=api.get_match_history_data(summoner_Ids[i])

File "C:\Users\Mark\PycharmProjects\Riot_API_Challenger_Stats\RiotAPI.py", line 52, in get_match_history_data

return self._request(api_url)

File "C:\Users\Mark\PycharmProjects\Riot_API_Challenger_Stats\RiotAPI.py", line 25, in _request

return response.json()

File "C:\Users\Mark\Anaconda3\lib\site-packages\requests\models.py", line 819, in json

return json.loads(self.text, **kwargs)

File "C:\Users\Mark\Anaconda3\lib\json\__init__.py", line 318, in loads

return _default_decoder.decode(s)

File "C:\Users\Mark\Anaconda3\lib\json\decoder.py", line 343, in decode

obj, end = self.raw_decode(s, idx=_w(s, 0).end())

File "C:\Users\Mark\Anaconda3\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)

这是里奥塔皮的10-25号线

^{pr2}$

回复如下:{"matches":[{"matchId":1878534497,"region":"NA","platformId":"NA1","matchMode":"CLASSIC","matchType":"MATCHED_GAME","matchCreation":1436223958539,"matchDuration":2097,"queueType":"RANKED_SOLO_5x5","mapId":11,"season":"SEASON2015","matchVersion":"5.12.0.348","participants":[{"teamId":200,"spell1Id":4,"spell2Id":7,"championId":15,"highestAchievedSeasonTier":"UNRANKED","timeline":{"creepsPerMinDeltas":{"zeroToTen":5.699999999999999,"tenToTwenty":6.9,"twentyToThirty":7.1},"xpPerMinDeltas":{"zeroToTen":358.5,"tenToTwenty":350.0,"twentyToThirty":364.20000000000005},"goldPerMinDeltas":{"zeroToTen":365.3,"tenToTwenty":337.5,"twentyToThirty":287.5},"csDiffPerMinDeltas":{"zeroToTen":-0.7,"tenToTwenty":-1.7000000000000004,"twentyToThirty":1.0999999999999999},"xpDiffPerMinDeltas":{"zeroToTen":-0.9000000000000057,"tenToTwenty":-114.75,"twentyToThirty":-121.19999999999999},"damageTakenPerMinDeltas":{"zeroToTen":480.5,"tenToTwenty":565.3,"twentyToThirty":1258.6},"damageTakenDiffPerMinDeltas":{"zeroToTen":-147.49999999999994,"tenToTwenty":-134.69999999999996,"twentyToThirty":15.0},"role":"DUO_CARRY","lane":"BOTTOM"},"masteries":[{"masteryId":4112,"rank":4},{"masteryId":4114,"rank":1},{"masteryId":4122,"rank":3},{"masteryId":4124,"rank":1},{"masteryId":4132,"rank":1},{"masteryId":4134,"rank":3},{"masteryId":4142,"rank":2},{"masteryId":4144,"rank":1},{"masteryId":4151,"rank":1},{"masteryId":4152,"rank":3},{"masteryId":4162,"rank":1},{"masteryId":4211,"rank":2},{"masteryId":4212,"rank":2},{"masteryId":4221,"rank":1},{"masteryId":4222,"rank":3},{"masteryId":4232,"rank":1}],"stats":{"winner":false,"champLevel":14,"item0":3031,"item1":0,"item2":3142,"item3":3035,"item4":1053,"item5":3250,"item6":3342,"kills":4,"doubleKills":1,"tripleKills":0,"quadraKills":0,"pentaKills":0,"unrealKills":0,"largestKillingSpree":3,"deaths":12,"assists":5,"totalDamageDealt":184710,"totalDamageDealtToChampions":27477,"totalDamageTaken":30740,"largestCriticalStrike":684,"totalHeal":2952,"minionsKilled":237,"neutralMinionsKilled":1,"neutralMinionsKilledTeamJungle":1,"neutralMinionsKilledEnemyJungle":0,"goldEarned":12074,"goldSpent":12065,"combatPlayerScore":0.....etc.}}]}]}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
>