同学们很快就要升上初三了,宣传委员小莉用Python程序制作了一个为同学们加油鼓劲的词云图(如图8),准备挂在班级墙上,这样既能鼓励大家,又能起到装饰作用。请阅读程序,回答小题:
import wordcloud import jieba text = open("加油鼓劲. txt", encoding='utf-8). readO seg_ generator = jieba. cut(text) seg_ list = "'. join(seg_ generator) w = wordcloud. WordCloud( font path = 'SourceHanSans-Normal. otf, stopwords=("的", "能", "和", "是","没有","了","不"]) w. generate(seg_ list) w. to_ file('加油鼓劲. png) print(词云图生成成功! ) |