-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab_2_intro_to_boto3.py
41 lines (32 loc) · 1.38 KB
/
lab_2_intro_to_boto3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import boto3
client = boto3.client('translate')
def translate_text():
response = client.translate_text(
Text='I am learning to code in AWS',
SourceLanguageCode='en',
TargetLanguageCode='fr'
)
#### Add the new text below this line ####
print(response) # this code is inside the function and will print the contents of the variable 'response'
translate_text() # This line will call our function. Without it, python will not do anything.
# terminal output: {'TranslatedText': "J'apprends à coder dans AWS", 'SourceLanguageCode': 'en', 'TargetLanguageCode': 'fr', 'ResponseMetadata': {'RequestId': 'db2e2966-000a-4474-97cd-337b6249b783', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'db2e2966-000a-4474-97cd-337b6249b783', 'cache-control': 'no-cache', 'content-type': 'application/x-amz-json-1.1', 'content-length': '101', 'date': 'Fri, 28 Feb 2020 10:14:32 GMT'}, 'RetryAttempts': 0}}
Return type
dict
Returns
Response Syntax
{
'TranslatedText': 'string',
'SourceLanguageCode': 'string',
'TargetLanguageCode': 'string',
'AppliedTerminologies': [
{
'Name': 'string',
'Terms': [
{
'SourceText': 'string',
'TargetText': 'string'
},
]
},
]
}