turtlepen画出小黄人

这篇博客介绍了如何利用Python的turtle模块一步一步绘制出可爱的小黄人,首先讲解了如何打开命令行并导入turtle模块,然后逐步指导在编辑器中编写代码实现小黄人的绘制过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.首先导入turtle模块

按住win+R键,输入cmd

pip install turtle

2.打开编辑器

输入

from turtle import *
pensize(3)
ht()#隐藏
speed(10)#设置速度,最快是0
#头
penup()
goto(90,130)
pendown()
begin_fill()
fillcolor('yellow')
left(90)
circle(125,180)
#身体
fd(150)
circle(125,180)
fd(150)
left(90)
end_fill()
#右眼镜+眼睛
pensize(5)
fd(50)
penup()
right(90)
color('black')
fd(15)
pendown()
begin_fill()
fillcolor('white')
circle(35)
end_fill()
right(90)
begin_fill()
fillcolor('black')
fd(50)
end_fill()
penup()
left(180)
fd(85)
dot(35,'brown')
dot(20,'black')
#左眼镜+眼睛
fd(35)
right(90)
fd(35)
left(90)
fd(35)
begin_fill()
fillcolor('white')
pendown()
circle(35)
end_fill()
penup()
left(90)
fd(35)
dot(35,'brown')
dot(20,'black')
right(90)
fd(35)
pendown()
fd(60)
left(90)
penup()
fd(15)
left(90)
pendown()
fd(60)
#裤子
penup()
goto(-158,-20)
begin_fill()
fillcolor('bl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值