获取SDK

pip install aliyun-python-sdk-core # 安装阿里云 SDK 核心库
pip install aliyun-python-sdk-nlp-automl # 安装NLP自学习平台SDK

使用示例

# -*- coding: utf8 -*-
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdknlp_automl.request.v20191111 import GetPredictResultRequest

# 创建 AcsClient 实例
client = AcsClient(
   "<your-access-key-id>",
   "<your-access-key-secret>",
   "<your-region-id>"
);

# 创建 request,并设置参数
request = GetPredictResultRequest.GetPredictResultRequest()
request.set_ModelId(1818)
request.set_Content("中华人民共和国人民解放军")

# 发起 API 请求并打印返回
response = client.do_action_with_exception(request)
print response