You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importrequestsimportosdata= {
'q': 'The Grate Great Pyramid of Giza (also known as the Pyramid of Khufu or the Pyramid of Cheops) is the oldest and largest of the three pyramids in the Giza pyramid complex.',
'source': 'en',
'target': 'ja',
'format': 'text'
}
url='https://translation.googleapis.com/language/translate/v2'token=os.environ['TOKEN']
headers= {
'Authorization': 'Bearer {}'.format(token),
'Content-Type': 'application/json',
}
res=requests.post(url, headers=headers, json=data)
print(res.json())
Google翻訳APIをpythonスクリプトで叩いて英語を日本語に翻訳する。
script
実行例
結果
Ref
Google Cloud の認証トークンを gcloud コマンドで取得する。環境変数でサービスアカウントファイルを指定する例。 · Issue #545 · YumaInaura/YumaInaura
The text was updated successfully, but these errors were encountered: