Skip to content

Commit 68ba5da

Browse files
OrisdaddyAxiosLeo
authored andcommitted
Improve python document.
1 parent 9ab6386 commit 68ba5da

File tree

2 files changed

+89
-55
lines changed

2 files changed

+89
-55
lines changed

docs/python/0-Usage-CN.md

+45-27
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,51 @@ from alibabacloud_tea_rpc.models import Config
3232
'''图像搜索示例'''
3333

3434

35-
f = open('pic.jpg', 'rb')
36-
# 初始化Request
37-
request = SearchImageByPicAdvanceRequest(
38-
instance_name='name',
39-
pic_content_object=f
40-
)
41-
42-
# 初始化Config
43-
config = Config(
44-
access_key_id='<your_accsee_key_id>',
45-
access_key_secret='<your_access_key_secret>',
46-
endpoint='<your_endpoint>',
47-
region_id='cn-shanghai',
48-
type='access_key'
49-
)
50-
51-
# 初始化RuntimeObject
52-
runtime_option = RuntimeOptions()
53-
54-
# 初始化Client
55-
client = Client(config)
56-
57-
# 调用api
58-
response = client.search_image_by_pic_advance(request, runtime_option)
59-
60-
print(response.to_map())
61-
f.close()
35+
with open('pic.jpg', 'rb') as f:
36+
# 初始化Request
37+
request = SearchImageByPicAdvanceRequest(
38+
instance_name='name',
39+
pic_content_object=f
40+
)
41+
42+
# 初始化Config
43+
config = Config(
44+
access_key_id='<your_accsee_key_id>',
45+
access_key_secret='<your_access_key_secret>',
46+
endpoint='<your_endpoint>',
47+
region_id='cn-shanghai',
48+
type='access_key'
49+
)
50+
51+
# 初始化RuntimeObject
52+
runtime_option = RuntimeOptions()
53+
54+
# 初始化Client
55+
client = Client(config)
56+
57+
# 调用api
58+
response = client.search_image_by_pic_advance(request, runtime_option)
59+
60+
print(response)
61+
print('request id:', response.request_id)
62+
print('code:', response.code)
63+
print('message:', response.msg)
64+
65+
# head
66+
print('docs return:', response.head.docs_return)
67+
print('docs found:', response.head.docs_found)
68+
print('search time:', response.head.search_time)
69+
70+
# pic info
71+
print('category id:', response.pic_info.category_id)
72+
print('region:', response.pic_info.region)
73+
print('all categories:', response.pic_info.all_categories)
74+
75+
# Auctions
76+
for aut in response.auctions:
77+
print('category id:', aut.category_id)
78+
print('product id:', aut.product_id)
79+
6280
```
6381

6482
## 参数说明

docs/python/0-Usage-EN.md

+44-28
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,50 @@ from alibabacloud_tea_rpc.models import Config
3030

3131
'''ImageSearch Example'''
3232

33-
34-
f = open('pic.jpg', 'rb')
35-
# init Request
36-
request = SearchImageByPicAdvanceRequest(
37-
instance_name='name',
38-
pic_content_object=f
39-
)
40-
41-
# init Config
42-
config = Config(
43-
access_key_id='<your_accsee_key_id>',
44-
access_key_secret='<your_access_key_secret>',
45-
endpoint='<your_endpoint>',
46-
region_id='cn-shanghai',
47-
type='access_key'
48-
)
49-
50-
# init RuntimeObject
51-
runtime_option = RuntimeOptions()
52-
53-
# init Client
54-
client = Client(config)
55-
56-
# call api
57-
response = client.search_image_by_pic_advance(request, runtime_option)
58-
59-
print(response.to_map())
60-
f.close()
33+
with open('pic.jpg', 'rb') as f:
34+
# init Request
35+
request = SearchImageByPicAdvanceRequest(
36+
instance_name='name',
37+
pic_content_object=f
38+
)
39+
40+
# init Config
41+
config = Config(
42+
access_key_id='<your_accsee_key_id>',
43+
access_key_secret='<your_access_key_secret>',
44+
endpoint='<your_endpoint>',
45+
region_id='cn-shanghai',
46+
type='access_key'
47+
)
48+
49+
# init RuntimeObject
50+
runtime_option = RuntimeOptions()
51+
52+
# init Client
53+
client = Client(config)
54+
55+
# call api
56+
response = client.search_image_by_pic_advance(request, runtime_option)
57+
58+
print(response)
59+
print('request id:', response.request_id)
60+
print('code:', response.code)
61+
print('message:', response.msg)
62+
63+
# head
64+
print('docs return:', response.head.docs_return)
65+
print('docs found:', response.head.docs_found)
66+
print('search time:', response.head.search_time)
67+
68+
# pic info
69+
print('category id:', response.pic_info.category_id)
70+
print('region:', response.pic_info.region)
71+
print('all categories:', response.pic_info.all_categories)
72+
73+
# Auctions
74+
for aut in response.auctions:
75+
print('category id:', aut.category_id)
76+
print('product id:', aut.product_id)
6177
```
6278

6379
## Parameter Specification

0 commit comments

Comments
 (0)