This topic describes how to install Python SDK and provides an operation example.


To download Python SDK, click either of the following links:


#!/usr/bin/env python
from aliyunsdkcore import client
from aliyunsdkcore.profile import region_provider
from aliyunsdksts.request.v20150401 import AssumeRoleRequest
# Construct an Alibaba Cloud client to initiate a request.
# Set the access key ID and access key secret.
REGIONID = 'cn-shanghai'
# Configure the STS endpoint to be accessed.
region_provider.add_endpoint('Sts', REGIONID, ENDPOINT)
# Initialize the client.
clt = client.AcsClient('<access-key-id>','<access-key-secret>', REGIONID)
# Construct the "AssumeRole" request.
request = AssumeRoleRequest.AssumeRoleRequest()
# Specify the Alibaba Cloud Resource Name (ARN) of the role.
# Set the session name. The session name is used to identify the user who is calling this API action.
# Initiate a request and obtain a response.
response = clt.do_action_with_exception(request)
print response