在线编辑api,自动生成代码

在线编辑

[https://console.cloud.tencent.com/api/explorer?Product=cvm&Version=2017-03-12&Action=RunInstances&SignVersion=](https://console.cloud.tencent.com/api/explorer](https://console.cloud.tencent.com/api/explorer?Product=cvm&Version=2017-03-12&Action=RunInstances&SignVersion=](https://console.cloud.tencent.com/api/explorer)

image.png

1.选择需求

  1. 如果对参数不明白,可以点击?查询,还不知道填什么可以在腾讯云的文档处搜索https://cloud.tencent.com/document/product

3.选择语言

填写好后可以在线执行代码

image.png

在Linux端执行

下载pip

yum -y install python-pip

下载腾讯云sdk

pip install tencentcloud-sdk-python
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.cvm.v20170312 import cvm_client, models 
try: 
    cred = credential.Credential("AKIDoNoBAydYKtDJDtG8SWheMXTAe2B7Y9gx", "DRWYqUvARbaKwKYYKsGEwWrwlLYZMtIT") 
    httpProfile = HttpProfile()
    httpProfile.endpoint = "cvm.tencentcloudapi.com"

    clientProfile = ClientProfile()
    clientProfile.httpProfile = httpProfile
    client = cvm_client.CvmClient(cred, "ap-guangzhou", clientProfile) 

    req = models.RunInstancesRequest()
    params = '{"InstanceChargeType":"POSTPAID_BY_HOUR","Placement":{"Zone":"ap-guangzhou-4"},"InstanceType":"S2.SMALL1","ImageId":"img-9qabwvbn","InternetAccessible":{"InternetChargeType":"TRAFFIC_POSTPAID_BY_HOUR","InternetMaxBandwidthOut":1},"InstanceCount":2,"InstanceName":"lvxin_{R:1}","LoginSettings":{"Password":"LvXin19961201"}}'
    req.from_json_string(params)

    resp = client.RunInstances(req) 
    print(resp.to_json_string()) 

except TencentCloudSDKException as err: 
    print(err) 

http://bbs.learnfuture.com/topic/1643

你可能感兴趣的:(在线编辑api,自动生成代码)