import requests, uuid, json
#腾讯云 1000万字符 550 元
#微软 $10/100 万个字符
# 终结点:
# 密钥1:
# 4VDl2sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5D
# 密钥2:
# NeEHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxPG
# 区域
# eastasia
# Add your key and endpoint
key = "4VDl2sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5D"
endpoint = "https://api.cognitive.microsofttranslator.com"
# location, also known as region.
# required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page.
location = "eastasia"
path = '/translate'
constructed_url = endpoint + path
params = {
'api-version': '3.0',
'from': 'en',
'to': [ 'zh']
}
headers = {
'Ocp-Apim-Subscription-Key': key,
# location required if you're using a multi-service or regional (not global) resource.
'Ocp-Apim-Subscription-Region': location,
'Content-type': 'application/json',
'X-ClientTraceId': str(uuid.uuid4())
}
# You can pass more than one object in body.
body = [{
'text': 'I would really like to drive your car around the block a few times!'
}]
request = requests.post(constructed_url, params=params, headers=headers, json=body)
response = request.json()
print(json.dumps(response, sort_keys=True, ensure_ascii=False, indent=4, separators=(',', ': ')))
微软翻译api
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 漏洞:Microsoft联机帐户 重置账户密码的API节点是常见的攻击矢量,攻击者通过提交海量的重置密码的代码组合...
- 海淘代购系统接入翻译 API 实现多国语言支持的技术,涵盖选择翻译 API、接入流程、代码示例以及注意事项等方面。...
- 不了解 DSOframer 的朋友,可以先参考文章 DSOframer 的简单介绍和资源整理。 大家在使用 DSO...
- 纯手工打造每一篇开源资讯与技术干货,数十万程序员和Linuxer已经关注。 长久以来,谷歌翻译(Google Tr...
- 01.理解powershell的特性 001.输出是对象 可以使用Get-Member查看输出的对象有那些成员,比...