语义相似度技术 error
Ta的回复 :贴出源码,方便调试。 import requests # client_id 为官网获取的AK, client_secret 为官网获取的SK url = 'https://aip.baidubce.com/oauth/2.0/token' data = {'grant_type':'client_credentials','client_id':'XXXXXX',\ 'client_secret':'XXXXXX'} response = requests.post(url,data=data) content = response.content content = eval(content) access_token = content['access_token'] request_url = "https://aip.baidubce.com/rpc/2.0/nlp/v2/word_emb_sim&access_token"+access_token headers = {'Content-Type':'application/json'} data = {"word_1":"政务","word_2":"专利"} response = requests.post(request_url,data=data,headers=headers) content = eval(response.content) print(content)