问题遇到的现象和发生背景 :
昨晚21点多,我用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 <genexpr>
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 "<pyshell#1>", line 1, in <module>
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
我的解答思路和尝试过的方法 :
查看translate源代码,无效(毕竟看不懂……)
我想要达到的结果:
翻译成功(结果为Здравейте)