GoogleTrans: AttributeError: 'NoneType' 对象没有属性 'group'



我正在研究一堆不同的库来更好地学习python,我想尝试使用GoogleTrans库制作一个程序。我使用 pip 下载了它,然后导入了它并阅读了如何使用它。我可以逐行复制,但它仍然会给我一个错误。这是我的代码,我正在做什么来获得这个

from googletrans import Translator
translator = Translator()
translateText = translator.translate("hola.")

这是我得到的错误:

Traceback (most recent call last):
File "C:UsersSteelZKDesktopProjectsgtts-translator.py", line 4, in <module>
translateText = translator.translate("hola.")
File "C:UsersSteelZKAppDataLocalProgramsPythonPython37libsite-packagesgoogletransclient.py", line 172, in translate
data = self._translate(text, dest, src)
File "C:UsersSteelZKAppDataLocalProgramsPythonPython37libsite-packagesgoogletransclient.py", line 75, in _translate
token = self.token_acquirer.do(text)
File "C:UsersSteelZKAppDataLocalProgramsPythonPython37libsite-packagesgoogletransgtoken.py", line 180, in do
self._update()
File "C:UsersSteelZKAppDataLocalProgramsPythonPython37libsite-packagesgoogletransgtoken.py", line 59, in _update
code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

固定库应该在这里我现在正在测试它们

https://pypi.org/project/py-translator/

pip3 install py_translator==1.8.9 

和代码

from py_translator import Translator
s = Translator().translate(text='Hello my friend', dest='es').text
print(s)

相关内容

  • 没有找到相关文章

最新更新