wordcloud—Generate Keywords

wordcloud—Generate Keywords

wordcloud is a third-party library that can be used to generate a word cloud for a text.·With the numpy, pillow, and other third-party libraries, wordcloud can be used to analyze the content and generate a word cloud according to the weights of the words.

In this example, wordcloud is used to design a word cloud named “makeblock keywords”.

import wordcloud

t = ‘ makeblock AI STEAM mBot Ranger Ultimate Codey halocode mBlock Neuron Laserbox’ #Set the content you want to output

w = wordcloud.WordCloud(background_color=’white’,width = 1000,height = 1000) #Set the format of the word cloud to be generated

w.generate(t) #Select the text to be generated

w.to_file(‘wordcloud.png’) #Set the file name and save the file to a local disk

The output of the program is as follows.