伙计们,我正试图翻译一列我的数据称为任务和面临的问题。首先我尝试使用googletrans
import pandas as pd
import numpy as np
!pip install googletrans==4.0.0rc1
from googletrans import Translator
translator = Translator()
df['Spanish'] = df['Task'].apply(translator.translate, src='en', dest='es').apply(getattr, args=('text',))
df
得到这个错误:
--> 122 if r.status_code != 200 and self.raise_Exception:
123 raise Exception('Unexpected status code "{}" from {}'.format(
124 r.status_code, self.service_urls))
AttributeError: 'Translator' object has no attribute 'raise_Exception'
添加time.sleep(1)
帮助我解决了这个问题。