官方SDK文档:https://github.com/TencentCloud/tencentcloud-sdk-python
安装
pip install tencentcloud-sdk-python
使用
# -*- coding: utf-8 -*-
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
# 导入对应产品模块的client models。
from tencentcloud.cvm.v20170312 import cvm_client, models
try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
cred = credential.Credential("secretId", "secretKey")
# 实例化要请求产品(以cvm为例)的client对象
client = cvm_client.CvmClient(cred, "ap-shanghai")
# 实例化一个请求对象
req = models.DescribeZonesRequest()
# 通过client对象调用想要访问的接口,需要传入请求对象
resp = client.DescribeZones(req)
# 输出json格式的字符串回包
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)