1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

python google translate

Posted at
# python -m pip install googletrans==3.1.0a0

from googletrans import Translator
import sys

args= sys.argv
if len(args) < 2:
    print('python3 translate.py 測試')
else:
    line = args[1]

    translator = Translator()
    translated = translator.translate(line, dest="zh-cn")
    
    print(line)
    print(translated.text)
    print()
    print('finished')
import pandas as pd
langdict = {0: {'zh-tw': '平安銀行'}}
df = pd.DataFrame(langdict).T
df['zh-cn'] = df['zh-tw'].apply(lambda x: translator.translate(x, src='auto', dest='zh-cn').text )
print(df)
1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?