json.decoder.JSONDecodeError:预期值:带有googletrans的第1行第1列(字符0)

时间:2019-06-24 15:11:03

标签: python-3.x google-translate

由于Google翻译API,我希望能够翻译,但无法正常工作

我使用python3.6.2 和googletrans-2.4.0 十分奇怪的是,它在15分钟前生效。我什么都没改变

from googletrans import Translator
translator = Translator()
translator.translate('안녕하세요.')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lib/python3.6/site-packages/googletrans/client.py", line 172, in translate
    data = self._translate(text, dest, src)
  File "lib/python3.6/site-packages/googletrans/client.py", line 81, in _translate
    data = utils.format_json(r.text)
  File "lib/python3.6/site-packages/googletrans/utils.py", line 62, in format_json
    converted = legacy_format_json(original)
  File "lib/python3.6/site-packages/googletrans/utils.py", line 54, in legacy_format_json
    converted = json.loads(text)
  File "/Users/.pyenv/versions/3.6.2/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/Users/.pyenv/versions/3.6.2/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/.pyenv/versions/3.6.2/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

1 个答案:

答案 0 :(得分:0)

Google对您在特定时间后可以进行的翻译数量有一​​个限制,并且错误消息只是告诉他们您已经达到该限制。您可能需要等待一段时间才能再次尝试。到那时,对您IP的禁令将被解除。