# 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)
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme