猫史档案馆


【Python作品分享】第一课欢欢喜喜介绍函

用户:小河鱼小河鱼查看:0 回复:0 评论:0 创建时间:2021-05-08T23:37:30


【作品展示】

center_image

 

【作品介绍】

实战操作联合编辑,也不知道对不对。

 

【作品源代码】

#导入词云库
import wordcloud
#导入分词库
import jieba
#导入imageio库
import imageio
#读取图片轮廓
mkl = imageio.imread('欢欢p.png')
#创建词云对象
wc1 = wordcloud.WordCloud(mask=mkl,background_color='white', font_path='simhei.ttf')
#读取文件内容
txt = open("欢欢.txt",'r',conding='utf-8').read()
#使用lcut()分词
txt = jieba.lcut(txt)
#使用join()拼接
txt = ''.join(txt)
#设置云图参数
wcl.generate(txt)
#生成云图片
Wcl.to-file('hhc.png')
#导入词云库
import wordcloud
#导入分词库
import jieba 
#导入imageio库
#读取图片轮廓
mk1 = imageio.imread('欢欢.p.png')
mk2 = imageio.imread('喜喜.p.png')
#创建图云对象
wc1 = wordcloud.WordCloud(
    mask=mk1, background_color='white', font_path='simhei.ttf')
wc2 = wordcloud.WordCloud(
    mask=mk2, background_color='white', font_path='simhei.ttf')
#读取文件内容
txt = open("欢欢.txt", 'r', encoding='utf-8').read()
txt = ''.join(txt)
#设计图云图参数
wc1.generate(txt)
wc2.generate(txt)
#生成图云参数
wc1.to_file('hhc.png')
ec2.to_file('xxc.png')
'''***********游戏窗口***********'''
# 设置游戏窗口的宽高
size = width, height = 800, 600
# 创建游戏窗口
screen = pygame.display.set_mode((size)
 # 创建游戏窗口的标题
pygame.display.set_caption("欢欢喜喜介绍函")
 # 加载角喵片
hh=pygame.image.load('欢欢p.png')
 # 加载角喵片
xx=pygame.image.load('喜喜p.png')
 # 加载角喵片
hhc=pygame.image.load('hhc.png')
 # 加载角喵片
xxc=pygame.image.load('xxc.png')
 while True:
 #遍历pygame事件列表
 for event in pygame.event.get():
 #判断事件是否为点击关闭按钮
if event.type == pygame.QUIT:
 #退出系统
sys.exit()
pygame.display.update()
 #设置时间延迟10秒(防止移动过快)
pygame.time.dlay(15)
#加载图片角色
xxc = pygame.image.load('xxc.png')
#设置两张角喵片坐标
x1 = 0
x2 = 600
y1 = 200
y2 = 170
while True:
          sys.exit()
   #将背景设置为白色
   screen.fill('white')
   #绘制欢欢图片
   screen.blit(hh,(x1,y1,))
   x1 = x1+2
   if x1 > 200:
       x1 =200
   #绘制喜喜图片
   screen. blit(xx,(x2,y2))
   #设置移动的步长
   x2 = x2-2
   y2 = y2+0.4
   if x2 < 400:
       x2 = 400
       y2 = 210
    pygame.display.update()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页