import jieba
txt=open("D:\红楼梦.txt","r",encoding='utf-8').read()
words=jieba.lcut(txt)
counts={}
names=open("D:\人名.txt","r",encoding='utf-8').read()
for word in words:
if len(word)==1:
continue
elif word == '贾母' or word == '老太太':
rword = '贾母'
elif word in '贾珍—尤氏'.split('—'): #split对字符串进行分割
rword = '贾珍'
elif word in '贾蓉—秦可卿'.split('-'):
rword = '贾蓉'
elif word in '贾赦—邢夫人'.split('-'):
rword = '贾赦'
elif word in '贾政—王夫人'.split('-'):
rword = '贾政'
elif word in '袭人-蕊珠'.split('-'):
rword = '袭人'
elif word i
红楼梦出现次数为前20的人物名称(含人物列表)
最新推荐文章于 2023-07-14 02:00:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)