python - json.decoder.JSONDecodeError:期望值:第 1 行第 18 列(字符 17),未发现任何故障
问题描述
也许你比我更了解那些解码错误,但我得到了这个错误:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\Try Me Btch\AppData\Local\Programs\Python\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "C:\Users\FlexGames\Desktop\Programming\Discord Bot\New Bot\main.commands.py", line 91, in on_message
await XPRole.save_last_msg(fb)
File "C:\Users\FlexGames\Desktop\Programming\Discord Bot\New Bot\New_Functions\XPRole.py", line 59, in save_last_msg
jsonhandle.update("last_message", lastmsg, "lastmsg")
File "C:\Users\FlexGames\Desktop\Programming\Discord Bot\New Bot\Functions\jsonhandle.py", line 56, in update
_load(jsonfile)
File "C:\Users\FlexGames\Desktop\Programming\Discord Bot\New Bot\Functions\jsonhandle.py", line 73, in _load
lmsgjson = json.load(lmsgload)
File "C:\Users\Try Me Btch\AppData\Local\Programs\Python\lib\json\__init__.py", line 293, in load
return loads(fp.read(),
File "C:\Users\Try Me Btch\AppData\Local\Programs\Python\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\Try Me Btch\AppData\Local\Programs\Python\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Try Me Btch\AppData\Local\Programs\Python\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 18 (char 17)
我的错误代码是:
elif jsonfile == "lastmsg":
global lmsgjson
with open("C:/Users/FlexGames/Desktop/Programming/Discord Bot/New Bot/lastmsg.json", "r") as lmsgload:
lmsgjson = json.load(lmsgload)
我不知道它可能是什么,因为我也试图删除完整的路径,所以只使用“lastmsg.json”,但我得到了同样的错误。
解决方案
解决方案:
你不能像
{"whatever": }
推荐阅读
- postgresql - postgres 从 9.6 升级到 11.5 后 Talend 6.5 中的问题
- optaplanner - 有效阻止无效解决方案
- python - 将数据框列与另一个数据框进行比较
- vb.net - 谁能告诉我为什么在 VB.NET 中使用 GetFiles 时在 NAS 驱动器上出现文件列表错误?
- ios - 在 Xcode(IB + 文件)中一次更改一个类的所有实例?
- wordpress - 在 wordpress 中获取“检测到活动的 PHP 会话”严重警告
- javascript - 按 id 和字段对表列进行排序不起作用
- javascript - 在 Angular 10 中使用 chart.js 创建多个动态堆叠图表?
- javascript - Vue-test-utils 包装器未通过
- sql - 使用 SQL Server 2016 从具有 5 亿行的字符串列中删除特殊字符