gpt4 book ai didi

Python (googletrans) - 属性错误 : 'NoneType' object has no attribute 'group'

转载 作者:行者123 更新时间:2023-12-05 03:45:13 28 4
gpt4 key购买 nike

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

同样需要解决方案

代码:

import googletrans
from googletrans import Translator
translator = Translator()
result = translator.translate('Mitä sinä teet')
print(result.src)
print(result.dest)
print(result.origin)
print(result.text)
print(result.pronunciation)

错误:


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

AttributeError: 'NoneType' object has no attribute 'group'

最佳答案

它在重新安装 googletrans 后有效

pip install googletrans==4.0.0-rc1

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

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