import wordcloud as w
import jieba
fname=input("Please enter a file name:") 
f=open(fname,"r") 
txt=f.read()
f.close()
if 65<=ord(txt[0])<=90 or 97<=ord(txt[0])<=122:
      ce=0
else:
      ce=1
if ce==1:
      ls=jieba.lcut(txt)
      txt=" ".join(ls)
from imageio import imread
pic=imread("heart.png")
w1=w.WordCloud(background_color="white",\
 font_path="msyh.ttc", mask=pic,stopwords='的和是')
w1.generate(txt)
j=0
for i in range(len(fname)):
      if fname[i]=='.':
            break
      else:
            j+=1
w1.to_file(fname[:j]+"WordCloud.png")
