官方sdk文档:https://github.com/aliyun/aliyun-openapi-python-sdk
安装
# Install the core library
pip install aliyun-python-sdk-core
# Install the ECS management library
pip install aliyun-python-sdk-ecs
使用
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkecs.request.v20140526 import DescribeInstancesRequest
from aliyunsdkecs.request.v20140526 import StopInstanceRequest
client = AcsClient(
"<access-key-id>",
"<access-key-secret>",
"<region-id>"
);
# Initialize a request and set parameters
request = DescribeInstancesRequest.DescribeInstancesRequest()
request.set_PageSize(10)
# Print response
response = client.do_action_with_exception(request)
print response