阿里云 Python SDK 频道

这里列出了所有阿里云 Python SDK

https://develop.aliyun.com/tools/sdk?#/python

阿里云 Python SDK 快速开始

这里是 Python SDK 的入门指南

https://help.aliyun.com/document_detail/53090.html

Python 3.0 Core

Python 3.0 以上版本使用的 Core SDK

https://pypi.org/project/aliyun-python-sdk-core-v3/

Aliyun 云监控

https://help.aliyun.com/document_detail/28617.html?spm=a2c4g.11186623.3.2.7ndBII

OSS 监控指标

https://help.aliyun.com/document_detail/31879.html?spm=a2c4g.11186623.2.1.WrkVRk

使用Python SDK

调用阿里云 Python SDK 的 3 个主要步骤:

  1. 创建Client实例(需要 Region IDAccessKey IDAccessKey Secret
  2. 创建API请求并设置参数
  3. 发起请求并处理应答或异常
# -*- coding: utf8 -*-
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
# 创建AcsClient实例
client = AcsClient(
   "<your-access-key-id>", 
   "<your-access-key-secret>",
   "<your-region-id>"
);
# 创建request,并设置参数
request = DescribeInstancesRequest.DescribeInstancesRequest()
request.set_PageSize(10)
# 发起API请求并显示返回值
response = client.do_action_with_exception(request)
print response