汉语分词工具包jieba

 1 #分词pip install jieba
 2 import jieba
 3 str="你真的真不知道我是谁吗?"
 4 res1=jieba.cut(str)
 5 print(list(res1))
 6 
 7 #cut_for_search更详细的分词
 8 res2=jieba.cut_for_search(str)
 9 print(list(res2))
10 
11 # ['你', '真的', '真不知道', '我', '是', '谁', '吗', '?']
12 # ['你', '真的', '真不', '不知', '知道', '真不知道', '我', '是', '谁', '吗', '?']
原文地址:https://www.cnblogs.com/open-yang/p/11253035.html