Python使用turtle画笑脸

python 复制代码
import turtle as t
t.pensize(5)            #设置画笔尺寸
t.color("red","yellow") #设置画笔颜色
t.begin_fill()          #开始填充
t.circle(150)           #绘制一个半径为100像素的圆
t.end_fill()            #结束填充

#画眼睛(左眼)
t.penup() #抬起画笔
t.goto(-40,170) #移动到指定坐标
t.pendown()
t.pensize(2)
t.color("black","black")
t.begin_fill()
t.circle(30)
t.end_fill()

#画眼睛(右眼)
t.penup()
t.goto(50,170)
t.pendown()
t.pensize(2)
t.color("black","black")
t.begin_fill()
t.circle(30)
t.end_fill()

#画嘴
t.penup()
t.goto(-55,120)
t.pendown()
t.right(90)
t.pensize(3)
t.color("red")
t.circle(60,180)
t.hideturtle()
t.done()

效果图如下:

相关推荐
该用户已不存在2 小时前
Mojo vs Python vs Rust: 2025年搞AI,该学哪个?
后端·python·rust
站大爷IP4 小时前
Java调用Python的5种实用方案:从简单到进阶的全场景解析
python
用户83562907805110 小时前
从手动编辑到代码生成:Python 助你高效创建 Word 文档
后端·python
侃侃_天下10 小时前
最终的信号类
开发语言·c++·算法
c8i10 小时前
python中类的基本结构、特殊属性于MRO理解
python
echoarts10 小时前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
liwulin050610 小时前
【ESP32-CAM】HELLO WORLD
python
Aomnitrix10 小时前
知识管理新范式——cpolar+Wiki.js打造企业级分布式知识库
开发语言·javascript·分布式
Doris_202311 小时前
Python条件判断语句 if、elif 、else
前端·后端·python
Doris_202311 小时前
Python 模式匹配match case
前端·后端·python