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()

效果图如下:

相关推荐
小雪_Snow8 分钟前
JavaScript 中的三种常用事件
开发语言·前端·javascript
肖爱Kun12 分钟前
C++设计策略模式
开发语言·c++·策略模式
dream_home840714 分钟前
图像算法模型NPU适配与算法服务实战指南
人工智能·python·算法·npu 图像服务
AIGS00120 分钟前
跨越语义鸿沟:企业本体语义平台的构建与落地
java·人工智能·python·机器学习·人工智能ai大模型应用
李可以量化23 分钟前
PTrade 量化策略实战:二八轮动策略深度解析(下)
python
Mx_coder28 分钟前
8年Java开发者AI转型第二周:RAG检索优化-从60%到90%准确率的3个关键技巧 (Day 13-14)
人工智能·python
灯澜忆梦37 分钟前
GO_面向对象_方法
开发语言·golang
布朗克16844 分钟前
Go 入门到精通-16-字符串深入
开发语言·后端·golang·字符串
自动化和Linux1 小时前
【pytest在pycharm中运行与CMD命令运行区别一】
python·pycharm·pytest
北冥you鱼1 小时前
Go flag 包详解:从命令行解析到实战应用
开发语言·后端·golang