LoginSignup
0
0

More than 1 year has passed since last update.

残プロ 第-48回 ~pythonとLanguageAppで翻訳~

Last updated at Posted at 2021-07-19

変数名が思いつかない!

皆さんはコーディングの際,変数名や関数名で困ったことはありますか?
英語力のない私にとって,これは深刻な問題です.

今回はLanguageAppとPythonを使ってコンソール上で文字の翻訳を行います.
なお,GoogleAppScriptの操作はこちらの記事を参考に行ってください.

translate.py
import requests
import sys

base_url = ('https://script.google.com/macros/s/hoge/exec')
text = sys.argv[1]
source = 'ja'
target = 'en'

url = '{}?text={}&source={}&target={}'.format(base_url, text, source, target)

print(requests.post(url).text)
>python translate.py 翻訳

translation

プログラムの内容はurlを用意してrequests.postで叩くだけです.
あとはpyinstaller等でexe化すれば翻訳アプリの完成です!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0