Python(googletrans)- AttributeError:“NoneType”对象没有属性“group”

K A*_*ish 4 python googletrans

尝试使用googletrans检测 Python 中的语言代码。但它会生成错误(有关信息,请参阅错误块)。

\n

需要相同的解决方案

\n

代码 :

\n
import googletrans\nfrom googletrans import Translator\ntranslator = Translator()\nresult = translator.translate('Mit\xc3\xa4 sin\xc3\xa4 teet')\nprint(result.src)\nprint(result.dest)\nprint(result.origin)\nprint(result.text)\nprint(result.pronunciation)\n
Run Code Online (Sandbox Code Playgroud)\n

错误:

\n
\nC:\\ProgramData\\Anaconda3\\lib\\site-packages\\googletrans\\gtoken.py in _update(self)\n     60 \n     61         # this will be the same as python code after stripping out a reserved word 'var'\n---> 62         code = self.RE_TKK.search(r.text).group(1).replace('var ', '')\n     63         # unescape special ascii characters such like a \\x3d(=)\n     64         code = code.encode().decode('unicode-escape')\n\nAttributeError: 'NoneType' object has no attribute 'group'\n
Run Code Online (Sandbox Code Playgroud)\n