This topic describes how to install SDKs for Python and provides sample code.

Background information

Installation

To install the SDKs for Python, you can run the pip command, or download the installation packages of the SDKs and add the packages to your project. For more information, see Quick start.

Example

The following code provides an example on how to use Resource Management SDK for Python to call the CreateResourceAccount operation. You can use OpenAPI Developer Portal to debug other API operations and obtain their sample code.

#!/usr/bin/env python
#coding = utf - 8
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkresourcemanager.request.v20200331.CreateResourceAccountRequest import CreateResourceAccountRequest
# Construct an Alibaba Cloud client that is used to initiate requests.
# When you construct the client, specify your AccessKey ID and AccessKey secret.
client = AcsClient('<accessKeyId>', '<accessKeySecret>', 'cn-shanghai')
# Construct the request object.
request = CreateResourceAccountRequest()
# Specify request parameters. For more information about the parameters, see API Reference.
request.set_accept_format('json')
request.set_DisplayName("test")
# Initiate the request and obtain a response.
response = client.do_action_with_exception(request)
#python2: print(response)
print(str(response, encoding = 'utf-8'))