from os import path
from wordcloud import WordCloud
from matplotlib import pyplot as plt

# 定义为列表会报错
frequencies = [(u'知乎',5),(u'小段同学',4),(u'曲小花',3),(u'中文分词',2),(u'样例',1)]

#修改为字典格式就ok了
frequencies1 = dict(frequencies)

# 直接传列表会报错,转入转换之后的格式就好了
wordcloud = WordCloud(max_font_size=40, relative_scaling=.5).fit_words(frequencies1)
plt.figure()
plt.imshow(wordcloud)
plt.axis("off")
plt.show()

wordcloud解决‘'list' object has no attribute 'items'

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
猜你喜欢
  • 2021-12-07
  • 2021-12-21
  • 2022-01-18
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案