python 调动AIP-SDK 无法正常执行。
opticaloptical 发布于2019-01 浏览:1412 回复:2
0
收藏
最后编辑于2020-05

我的版本是3.6

代码如下:(直接照着敲的)

# -*- coding: utf-8 -*-

from aip import AipNlp
""" 你的 APPID AK SK """
APP_ID = '----'
API_KEY = '----'
SECRET_KEY = '----'
client = AipNlp(APP_ID, API_KEY, SECRET_KEY)
text = "百度是一家高科技公司"
client.lexer(text)

报错:

"D:\Program Files\Python36\python.exe" D:/PycharmProjects/baiduAI/分词.py
Traceback (most recent call last):
File "D:/PycharmProjects/baiduAI/分词.py", line 10, in
client.lexer(text)
File "D:\Program Files\Python36\lib\site-packages\aip\nlp.py", line 171, in lexer
return self._request(self.__lexerUrl, self.__processData(data))
File "D:\Program Files\Python36\lib\site-packages\aip\nlp.py", line 57, in __processData
return json.dumps(content)
File "D:\Program Files\Python36\lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "D:\Program Files\Python36\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "D:\Program Files\Python36\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "D:\Program Files\Python36\lib\json\encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable

Process finished with exit code 1

请帮助看看,问题在哪里?谢谢!

收藏
点赞
0
个赞
共2条回复 最后由asura13com回复于2020-05
#3asura13com回复于2020-05

。。。居然是年前的问题

亲,最后怎么解决的啊

0
#2asura13com回复于2020-05

好多人遇到这个问题

 

0
TOP
切换版块