python翻译库translate报错

from translate import Translator
print(Translator(from_lang = "Chinese", to_lang = "Bulgarian").translate("你好"))

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\translate\translate.py", line 45, in 
    return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\translate\providers\mymemory_translated.py", line 49, in get_translation
    next_best_match = next(match for match in matches)
StopIteration
 
The above exception was the direct cause of the following exception:
 
Traceback (most recent call last):
  File "", line 1, in 
    print(Translator(from_lang = "Chinese", to_lang = "Bulgarian").translate("你好"))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\translate\translate.py", line 45, in translate
    return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)
RuntimeError: generator raised StopIteration

解决:

from translate import Translator
 
 
print(Translator(from_lang="zh", to_lang="bg-BG").translate("你好"))

你可能感兴趣的:(python)