代码:%matplotlib inline
import matplotlib.pyplot as plt
from wordcloud import WorldCloud,ImageColorGenerator
import numpy as np
import PIL.Image as Image
f=open("D:\桌面\Desktop\my love.txt")
word_space_split=f.read()
coloring=np.array(Image.open("D:\桌面\Desktop\LOVE.jpg"))
my_wordcloud=WorldCloud(backcloud_color="white",
max_word=120,
mask=coloring,
max_font_size=80,
min_font_size=20,
random_state=42,
scale=10,
font_path="C:\Windows\Fonts\STFANGSO.TTF").generate(chtext)
image_colors=ImageColorGenerator(coloring)
plt.imshow(my_wordcloud.recolor(color.func==image_colors))
plt.imshow(my_wordcloud)
plt.axis("off")
报错:ImportError Traceback (most recent call last)
<ipython-input-14-b03400848b5c> in <module>
1 get_ipython().run_line_magic('matplotlib', 'inline')
2 import matplotlib.pyplot as plt
----> 3 from wordcloud import WorldCloud,ImageColorGenerator
4 import numpy as np
5 import PIL.Image as Image
ImportError: cannot import name 'WorldCloud' from 'wordcloud' (D:\anaconda3\lib\site-packages\wordcloud\__init__.py)