【问题标题】:How to fix: AttributeError: 'NoneType' object has no attribute 'group'如何修复:AttributeError:“NoneType”对象没有属性“组”
【发布时间】:2021-08-29 15:28:32
【问题描述】:

我正在运行以下代码:-

from googletrans import Translator, constants
from pprint import print


# init the Google API translator
translator = Translator()

# translate a spanish text to english text (by default)
translation = translator.translate("Hola Mundo")


print("{} ({}) --> {} ({})".format(translation.origin, translation.src, translation.text, translation.dest))

运行此代码时,我收到错误消息:AttributeError: 'NoneType' object has no attribute 'group'

我不知道如何解决这个错误。

我在 stackoverflow 上看到过其他答案,但没有用。

有人知道怎么解决吗?

以下是完整错误的屏幕截图:-

【问题讨论】:

    标签: python python-3.x google-api translation google-translate


    【解决方案1】:

    要修复此错误,您必须卸载当前的 googletrans 版本并使用以下命令安装新版本:

    pip3 uninstall googletrans
    pip3 install googletrans==3.1.0a0
    

    再次运行代码,它应该会修复错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多