
# Python SDK使用范例
以[同步执行函数](https://apiexplorer.developer.huaweicloud.com/apiexplorer/sdk?product=FunctionGraph&api=InvokeFunction)为例，提供封装后的SDK。为了保证您成功使用以下示例代码，您需要先添加对应语言的SDK依赖。
表1Python SDK信息说明 
| SDK信息 | 说明                                                                                                                                                                                                           |
|:---|:---|
| 安装    | ``` pip install huaweicloudsdkfunctiongraph ```                                                                                                                                                              |
| 相关链接  | [SDK依赖包地址](https://pypi.org/project/huaweicloudsdkfunctiongraph/) [Python SDK使用说明](https://github.com/huaweicloud/huaweicloud-sdk-python-v3/blob/master/README_CN.md) |
   
SDK的请求参数、响应参数、请求示例和响应示例与对应的API一致，具体参数和示例说明请参见[同步执行函数](https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0125.html)接口。
**SDK调用示例**
```
# coding: utf-8
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkfunctiongraph.v2.region.functiongraph_region import FunctionGraphRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkfunctiongraph.v2 import *
if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext， which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example， AK and SK are stored in environment variables for authentication. Before running this example， set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('os').getenv("CLOUD_SDK_SK")
    credentials = BasicCredentials(ak, sk) \
    client = FunctionGraphClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(FunctionGraphRegion.value_of("<YOUR REGION>")) \
        .build()
    try:
        request = InvokeFunctionRequest()
        listInvokeFunctionRequestBodybody = {
            "k": "v"
        }
        request.body = listInvokeFunctionRequestBodybody
        response = client.invoke_function(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
```
![](https://support.huaweicloud.com/sdkreference-functiongraph/public_sys-resources/note_3.0-zh-cn.png)
AK/SK、region（EndPoint）、project_id（项目ID）的获取请参见[AK/SK签名认证操作指导](https://support.huaweicloud.com/devg-apisign/api-sign-provide.html)。
func_name、version在函数界面上获取。
xCFFRequestVersionRequest：返回体格式，取值v0，v1。v0：默认返回文本格式；v1：默认返回json格式，sdk需要使用此值。
