# define Python user-defined exceptions
class Error(Exception):
"""Base class for other exceptions"""
pass
class NotTranslated(Error):
"""Raised when the input value is zero"""
pass
try:
test_string ="ok ਜੌਨ ਲੂਮਰ ਇੱਕ ਬਲੌਗਰ ਅਤੇ ਪੋਡਕੇਸਟਰ ਹੈ ਜਿਸਦੀ ਵੈਬਸਾਈਟ ਸਾਰੀਆਂ ok"
res = test_string.split()
for i in res:
blob = TextBlob(i)
print(blob.translate(to='en'))
raise NotTranslated
except NotTranslated:
print("Not Translated,!")
print()
**我正在使用文本块翻译混合语言,有时会抛出API错误“未翻译”我想在try块中处理此问题,到目前为止,我已尝试过此方法,但未获得任何高度赞赏的帮助**
目前没有回答
相关问题 更多 >
编程相关推荐