没有人一开始就能想清楚,只有做起来,目标才会越来越清楚。——马克·扎克伯格
下载jieba
pip3 install jieba
创建测试文件
jiebaDemo.txt
编写代码
import jieba
filepath = input("input your path:")
with open(filepath,encoding='utf-8') as f:
words = jieba.lcut(f.read())
print(words)
执行结果
得到的结果是一个list
列表
封装为一个函数
import jieba
def jiebaFunc(filepath):
with open(filepath,encoding='utf-8') as f:
words = jieba.lcut(f.read())
print(words)