在powerpoint里打入“仁”字,QQ截图,在QQ对话框里保存为font.png图片。

具体代码如下:

#GovRptWorldCloudv1
import jieba
import wordcloud
from imageio import imread
mask = imread("ren.png")
f = open("论语.txt","r",encoding = "utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud( font_path= "msyh.ttc", mask= mask,\
    width = 1000, height= 700, background_color= "white",\
    )
w.generate(txt)
w.to_file("renwordcloud.png")
        

结果如下