Python Google API没有返回结果

2024-04-27 14:06:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用python3.5,并尝试在python上运行googlecloud自然语言api。 我试过这个代码:

from googleapiclient import discovery
lang_service = discovery.build('language', 'v1beta1', developerKey= 'mykey')
body = {
        'document': {
            'type': 'PLAIN_TEXT',
            'content': 'Google Inc Apple Inc',
        },
        'features': {
            'extract_syntax': True,
        },
        'encodingType': encoding,
    }
ret = lang_service.documents().annotateText(body=body).execute()
print (ret)

mykey被我的api密钥替换。 代码没有出错,但我没有给我任何结果。你知道吗

顺便说一句,如果你知道如何在python上运行google自然语言api,请帮助我!你知道吗


Tags: 代码fromimportbuildapilangservicebody