为什么我得到一个HTTP错误400时使用TextBlob,我如何解决?



我在使用TextBlob库时遇到一些问题。我试着运行一段非常简单的代码,像这样:

from textblob import TextBlob
text1 = TextBlob('I looked for Mary and Samantha at the bus station')
a = text1.detect_language()
print(a)

它不断给我这个错误:

``
639 class HTTPDefaultErrorHandler(BaseHandler):
640     def http_error_default(self, req, fp, code, msg, hdrs):
--> 641         raise HTTPError(req.full_url, code, msg, hdrs, fp)
642 
643 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 400: Bad Request
``

尝试使用:

from textblob.translate import Translator
translate = Translator()
text1 = 'I looked for Mary and Samantha at the bus station'
a = translate.detect(text1)
print(a)

这对我有用😀

相关内容

最新更新