def get_token(api, secret):
param = {
'grant_type': 'client_credentials',
'client_id': api,
'client_secret': secret
}
token = requests.get(token_url, params=param).json()
return token['access_token']
def word_vector(api_key, secret_key, word):
access_token = get_token(api_key, secret_key)
params = {
'access_token': access_token
}
header = {
'Content-Type': 'application/json'
}
word = word.encode('gbk')
data = {
"word": word
}
content = requests.post(url, headers=header, params=params, data=data).json()
print(content)
python 调用接口总是返回282004报错求大佬指点
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
data是dict的话默认是按表单形式post的,不是json