Wordcloud安装成功,但是还是报错,虚心请教
#GovRptv1.pyimport jieba
import wordcloud
f = open("新时代中国特色社会主义.txt","r",encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = "".join(ls)
w = wordcloud.WordCloud( font_path = "msyh.ttc", width = 1000, height = 700, \
background_color = "white")
w.generate(txt)
w.to_file("grwardcloud.png")
报错:
Traceback (most recent call last):
File "F:\PYECourse\#GovRptv1.py", line 5, in <module>
t = f.read()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 0: invalid start byte
>>>