代码改变世界

jieba 分词不显示日志

2019-06-27 09:58  JohnRain  阅读(1590)  评论(0编辑  收藏  举报

问题

每一次我用jieba进行分词的时候,都会有

Building prefix dict from the default dictionary ...
Loading model from cache /tmp/jieba.cache
Loading model cost 0.128 seconds.
Prefix dict has been built succesfully.

这样的提示。怎么去除这些提示呢?

解决方案

import logging
jieba.setLogLevel(logging.INFO)

jieba.setLogLevel(20)

参考:

https://github.com/fxsjy/jieba/issues/529