首页 > 解决方案 > 自动更正python3包错误TypeError:JSON对象必须是str,而不是'bytes'

问题描述

我使用命令pip install autocorrect安装了自动更正包,所有安装正确,但示例代码:

    from autocorrect import Speller
     check = Speller(lang='en')
    check("does this sentece have misspelled wordz?")

给我这个包文件中的错误:

回溯(最后一次调用):文件“D:\abk\study\testauto.py”,第 3 行,检查 = Speller(lang='en') 文件“C:\Users\Abdelrahman Bonna\AppData\Local\ Programs\Python\Python35-32\lib\site-packages\autocorrect__init__.py”,第 58 行,在init self.nlp_data = load_from_tar(lang) 文件“C:\Users\Abdelrahman Bonna\AppData\Local\Programs\Python\ Python35-32\lib\site-packages\autocorrect__init__.py”,第 52 行,在 load_from_tar 返回 json.load(file) 文件“C:\Users\Abdelrahman Bonna\AppData\Local\Programs\Python\Python35-32\lib \json__init__.py”,第 268 行,加载 parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) 文件“C:\Users\Abdelrahman Bonna\AppData\Local\Programs\Python\Python35-32\lib\json__init__.py",第 312 行,加载 s。name )) TypeError:JSON 对象必须是 str,而不是 'bytes'

我在这个包中使用 python 3.5 并破坏了 Windows 10。

标签: pythonpython-3.xpackagepypiautocorrect

解决方案


推荐阅读