gpt4 book ai didi

python - 属性错误 : 'NoneType' object has no attribute 'group' googletrans python

转载 作者:行者123 更新时间:2023-12-03 23:59:05 24 4
gpt4 key购买 nike

Windows 7

Python 3.8.2

谷歌翻译 3.0.0

from googletrans import Translator

text = 'hello'
translator = Translator()
result = translator.translate(text).src
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\AB\AppData\Local\Programs\Python\Python38-32\lib\site-packages\
googletrans\client.py", line 182, in translate
data = self._translate(text, dest, src, kwargs)
File "C:\Users\AB\AppData\Local\Programs\Python\Python38-32\lib\site-packages\
googletrans\client.py", line 78, in _translate
token = self.token_acquirer.do(text)
File "C:\Users\AB\AppData\Local\Programs\Python\Python38-32\lib\site-packages\
googletrans\gtoken.py", line 194, in do
self._update()
File "C:\Users\AB\AppData\Local\Programs\Python\Python38-32\lib\site-packages\
googletrans\gtoken.py", line 62, in _update
code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

在一切正常之前,稍后这些错误开始出现,现在每次函数调用后都会出现此错误。

最佳答案

试试 google_trans_new。 https://github.com/lushan88a/google_trans_new

pip install google_trans_new
from google_trans_new import google_translator
translator = google_translator()
translate_text = translator.translate('Hello!',lang_src='en', lang_tgt='de')
print(translate_text)

-> 你好!

关于python - 属性错误 : 'NoneType' object has no attribute 'group' googletrans python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65144681/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com