Merge pull request #3 from fxsjy/master

捕获明确的错误
This commit is contained in:
项超 2013-05-10 02:56:02 -07:00
commit 4a9f2d1e19

View File

@ -193,7 +193,7 @@ def cut(sentence,cut_all=False):
if not isinstance(sentence, unicode):
try:
sentence = sentence.decode('utf-8')
except:
except UnicodeDecodeError:
sentence = sentence.decode('gbk','ignore')
re_han, re_skip = re.compile(ur"([\u4E00-\u9FA5a-zA-Z0-9+#&\._]+)"), re.compile(ur"(\s+)")
if cut_all: