Python
파이썬 번역 - googletrans
앗사비
2022. 1. 20. 11:39
728x90
https://github.com/ssut/py-googletrans
# pip install googletrans==4.0.0rc1
from googletrans import Translator
tran = Translator()
result = tran.translate('hello', dest='ko')
print(result.text)
아직 정식 버전이 아니라 그런지 bulk 기능은 오류 발생
tran = Translator()
strings = ['hello','world']
results = tran.translate(strings, dest='ko')
for result in results:
print(result.text)
bulk 대신 for 구문으로 여러개 번역하기
tran = Translator()
strings = ['hello','world']
for s in strings:
result = tran.translate(s, dest='ko')
print(result.text)
728x90