FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/haha/Desktop.txt'



```python
from matplotlib import pyplot as plt    #绘图,数据可视化
from wordcloud import WordCloud#词云
from PIL import Image      #图片处理
import numpy as np     #矩阵运算
import sqlite3     #数据库


#准备词云所需的文字(词)

f = open(r'C:/Users/haha/Desktop.txt', encoding = 'utf-8')
t = f.read()
f.close()
cut=jieba.cut(t)
string=' '.join(cut)
print(len(string))


img=Image.open(r'.\static\assets\imgs\tyle.jpg')#打开遮罩图片
img_array=np.array(img)#将图片转换为数组
wc=WordCloud(
    background_color='white',
    mask=img_array,
    font_path=r'C:/Windows/Fonts/msyh.ttc'#字体所在位置:C:\windows\Fonts
)

wc.generate_from_text(string)
#wc=WordCloud(collocations=False,font_path=font,width=1400,height=1400,margin=2).generate(text.lower())
#绘制图片
fig=plt.figure(1)
plt.imshow(wc)
plt.axis('off')#是否显示坐标轴
plt.savefig(r'.\static\assets\img\mm.jpg',dpi=600)#dpi是调节清晰度
plt.show()#显示词云

#输出词云图片到文件

```

路径错了,看下是windows还是linux操作系统, "/"或者""或者"//"

windows下:

print("C:\\Windows\\notepad.exe")
或者
print(r"C:\Windows\notepad.exe")

Linux下:

print("./test.exe")