from wordcloud import WordCloud
with open('E:\诗词.txt',encoding="utf-8")as file:
text=file.read()
wordcloud=WordCloud(font_path="E:\Python\u_msgpack_python-2.7.1-py3-none-any.whl",
background_color="black",width=600,
height=300,max_words=50).generate(text)
image=wordcloud.to_image()
image.show()
出现错误:
File "<ipython-input-2-6df413e6e4ba>", line 6 wordcloud=WordCloud(font_path="E:\Python\u_msgpack_python-2.7.1-py3-none-any.whl", ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 9-10: truncated \uXXXX escape