教你用Python画个可爱的皮卡丘!(附完整源码)
Posted 南柯树下
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了教你用Python画个可爱的皮卡丘!(附完整源码)相关的知识,希望对你有一定的参考价值。
![](https://image.cha138.com/20230315/6c470ca751d94061a881e9c157453af8.jpg)
版权声明:原创不易,本文禁止抄袭、转载,侵权必究!
一、去吧!皮卡丘!
使用turtle(海龟库)制作而成,感觉挺好玩的,哈哈@>_<@,效果如下:
由于源码过长,这里仅展示部分代码:
from turtle import * import turtle as t from random import * def infoPrt(): print(\'coordinate: \' + str(t.pos())) print(\'angle: \' + str(t.heading())) t.pensize(3) t.hideturtle() t.colormode(255) t.color("black") t.setup(700, 650) t.speed(1) t.st() t.pu() t.goto(-210,86) t.pd() infoPrt() # 头 print(\'头\') t.seth(85) t.circle(-100,50) infoPrt() t.seth(25) t.circle(-170,50) infoPrt() # 右耳 print(\'右耳\') t.seth(40) t.circle(-250,30) infoPrt() # 右耳尖 t.begin_fill() # 左 t.circle(-250,22) # 右 t.seth(227) t.circle(-270, 15) prePos = t.pos() infoPrt() # 下 t.seth(105) t.circle(100, 32) t.end_fill() t.pu() t.setpos(prePos) t.pd() t.seth(212) t.circle(-270, 28) prePos = t.pos() t.pu() t.goto(t.xcor()+5,t.ycor()-2) t.pd() # 躯干 print(\'躯干\') t.seth(280) t.circle(500, 30) infoPrt() # 臀部 print(\'臀部\') t.seth(120) t.circle(150, -11) p_tail=t.pos() t.circle(150, -44) p_butt=t.pos() infoPrt() # 尾巴 t.pu() t.setpos(p_tail) t.pd() t.begin_fill() t.seth(50) t.fd(25) t.seth(-50) t.fd(30) p_tail1=t.pos t.seth(-140) t.fd(36) t.end_fill() t.seth(39)
想要学习turtle(海龟库)的同志可以看官方教程文档:
https://docs.python.org/3.9/library/turtle.html
四、完整源码下载
关注我的原创公众号【小鸿星空科技】,回复【皮卡丘】关键词获取完整源码
五、作者Info
Author:南柯树下,Goal:让编程更有趣!
原创微信公众号:『小鸿星空科技』,专注于算法、爬虫,数据分析、自然语言处理,机器学习等,期待你的关注,让我们一起成长、一起Coding!
版权声明:本文禁止抄袭、转载 ,侵权必究!
— —— —— —— — END —— —— —— —— ————
欢迎扫码关注我的公众号
小鸿星空科技
以上是关于教你用Python画个可爱的皮卡丘!(附完整源码)的主要内容,如果未能解决你的问题,请参考以下文章
❤️用Python+turtle模块实现生成皮卡丘❤️(附源码)
教你用python制作一个爬虫软件,城市二手房信息一览无余。。(附源码)
教你用python爬取王者荣耀英雄皮肤图片,并将图片保存在各自英雄的文件夹中。(附源码)