标题:Wordcloud安装成功,但是还是报错,虚心请教
只看楼主
starry1212
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2020-6-6
 问题点数:0 回复次数:0 
Wordcloud安装成功,但是还是报错,虚心请教
#GovRptv1.py
import 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
>>>
搜索更多相关主题的帖子: 成功 txt 报错 安装 byte 
2020-06-06 16:32



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-501986-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.241400 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved