【Python小随笔】词云

后端:

        message = {}
            list_f = models.Value_A.objects.all()
            str_list = ""
            for data in list_f:
                str_list = str_list +data.title + ","
            BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
            w = wordcloud.WordCloud(width=1000, height=400,max_words=200,background_color='white',font_path='msyh.ttc')
            w.generate(str_list)
            w.to_file(BASE_DIR + '/static/ciyun/output1.png')
            message['ciyun'] = '/static/ciyun/output1.png'

前端:

 <div id="ciyun" style="width: 1000px;height:400px;margin-top: 20px;margin-left: 230px">
        <img :src="ciyun" style="width: 100%;height: 100%">
    </div>


 el: '#app',
        data: {
            ciyun: ""
        },


this.ciyun = response.data.ciyun

 

posted @ 2022-04-14 10:27  PythonNew_Mr.Wang  Views(43)  Comments(0)    收藏  举报