如何调用腾讯云的api
最近想尝试使用腾讯翻译君的翻译功能,想通过调用腾讯云的api来是用,但是腾讯云的python的SDK的文档和示例看不懂,网上也没有找到有用的资源。尤其是鉴权这一块。希望各位能帮忙解释一下。如果能附上代码就更好了。非常感谢 本帖最后由 均昊山 于 2020-7-15 09:36 编辑pip install tencentcloud-sdk-python 安装腾讯云开发工具包
https://cloud.tencent.com/document/product/494/42698#api-explorer 查找相关云 产品sdk
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.tmt.v20180321 import tmt_client, models
try:
cred = credential.Credential("1111111111111", "1111111111111111111111")
httpProfile = HttpProfile()
httpProfile.endpoint = "tmt.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = tmt_client.TmtClient(cred, "ap-guangzhou", clientProfile)
req = models.TextTranslateRequest()
params = '{\"SourceText\":\"你好\",\"Source\":\"en\",\"Target\":\"zh\"}'
req.from_json_string(params)
resp = client.TextTranslate(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)
腾讯云有提供API Explorer 在线调试的~.~ 昨晚找到了,踏破铁鞋无觅处 瓜子仁 发表于 2020-7-16 02:13
昨晚找到了,踏破铁鞋无觅处
柳暗花明又一村,加油{:10_264:}
页:
[1]