01: 腾讯云API
2021-06-10 11:05
标签:set model int col 服务器 from 上海 secret pytho 1、腾讯云SDK使用举例 网址:https://cloud.tencent.com/document/sdk/Python 2、地域相关接口 11111111111111111111 01: 腾讯云API 标签:set model int col 服务器 from 上海 secret pytho 原文地址:https://www.cnblogs.com/xiaonq/p/10607048.html1.1 云服务器
#! /usr/bin/env 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
secretId = "*********************************"
secretKey = "*********************************"
try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
cred = credential.Credential(secretId=secretId, secretKey=secretKey)
# 实例化要请求产品(以cvm为例)的client对象
client = cvm_client.CvmClient(cred, "ap-shanghai") # 以查询可用区接口为例
# 实例化一个请求对象
req = models.DescribeZonesRequest()
# 通过client对象调用想要访问的接口,需要传入请求对象
resp = client.DescribeZones(req)
# 输出json格式的字符串回包
print ‘##########################‘
print resp.to_json_string()
except TencentCloudSDKException as err:
print(err)
ret = {
"TotalCount": 5,
"ZoneSet": [{
"ZoneState": "UNAVAILABLE",
"ZoneName": "上海一区",
"Zone": "ap-shanghai-1",
"ZoneId": "200001"
}, {
"ZoneState": "AVAILABLE",
"ZoneName": "上海二区",
"Zone": "ap-shanghai-2",
"ZoneId": "200002"
}, {
"ZoneState": "AVAILABLE",
"ZoneName": "上海三区",
"Zone": "ap-shanghai-3",
"ZoneId": "200003"
}, {
"ZoneState": "AVAILABLE",
"ZoneName": "上海四区",
"Zone": "ap-shanghai-4",
"ZoneId": "200004"
}, {
"ZoneState": "UNAVAILABLE",
"ZoneName": "上海五区",
"Zone": "ap-shanghai-5",
"ZoneId": "200005"
}],
"RequestId": "ebd821c7-ac5c-4dfd-8038-762346bd14d1"
}
上一篇:慢启动与拥塞窗体