使用wordcloud生成中文词云的汉字编码问题

用python对市长信箱的回复选登进行分析,需要作词云图,选择wordcloud包来实现。

网上很多都介绍了生成中文词云需要指定中文字体的路径,但我在使用中还遇到了utf8编码与unicode编码的转换问题。即utf8编码的字符串需要先转换为unicode编码,然后再送入wordcloud的fit_words方法才能正确显示中文词云。

示例代码如下:

rec=records
for i in range(0,len(records)):
	rec[i]=(unicode(records[i][0]),records[i][1])

tags=dict(rec)
wordcloud=WordCloud(font_path="/Users/wangliangxu/Desktop/SimSun.ttf",width=1200,height=600,max_words=400).fit_words(tags)

已发布

分类

来自

标签:

评论

《 “使用wordcloud生成中文词云的汉字编码问题” 》 有 13 条评论

  1. online order androxal generic in us

    Buying androxal without a perscription

  2. online order enclomiphene buy online canada

    buy enclomiphene online no rx

  3. how to buy rifaximin cost usa

    get rifaximin online mastercard accepted

  4. discount xifaxan generic now

    discount xifaxan no prescription

  5. order staxyn generic online mastercard

    buying staxyn price discount

  6. how to order avodart using mastercard

    buy cheap avodart cost tablet

  7. ordering flexeril cyclobenzaprine generic united states

    get flexeril cyclobenzaprine purchase generic

  8. compare dutasteride prices at major pharmacies

    buy dutasteride generic switzerland

  9. gabapentin fed ex cheap

    buying gabapentin generic discount

  10. online order fildena generic drug

    get fildena cheap real

  11. cheapest buy itraconazole generic in usa

    cheapest buy itraconazole generic online canada

  12. kamagra generické

    koupit kamagra online nový zéland

  13. achat kamagra en paris

    acheter kamagra

回复 kamagra générique le moins cher 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注