Loading... > 用户很广不多介绍,如果需要搭建webAPI可以参考 [python伪原创工具之webAP](http://blog.11dz.cn/archives/342.html) 这篇文章 ```python # coding=utf-8 import synonyms from jieba import posseg as pseg def words_change(words): # 传入句子,变形返回 words_tuple = pseg.lcut(words) print(words_tuple) word_list = [] for word, flag in words_tuple: if flag == 'a' or flag == 'ad' or flag == 'v': # 词性判断 seg_list = (synonyms.nearby(word))[0] if len(seg_list) <= 1: word = word else: word = seg_list[1] word_list.append(word) return "".join(word_list) ``` 最后修改:2022 年 04 月 25 日 © 允许规范转载 打赏 赞赏作者 微信 赞 0 如果觉得我的文章对你有用,请随意赞赏