好的,下面是一段用Python画一只小海龟的代码:

import turtle

# 创建画布和海龟对象
canvas = turtle.Screen()
canvas.bgcolor("lightblue")
t = turtle.Turtle()

# 绘制海龟的头部
t.penup()
t.goto(0, 100)
t.pendown()
t.fillcolor("green")
t.begin_fill()
t.circle(50)
t.end_fill()

# 绘制眼睛
t.penup()
t.goto(0, 120)
t.pendown()
t.fillcolor("white")
t.begin_fill()
t.circle(10)
t.end_fill()
t.fillcolor("black")
t.begin_fill()
t.circle(5)
t.end_fill()

# 绘制海龟的身体
t.penup()
t.goto(0, 50)
t.pendown()
t.fillcolor("green")
t.begin_fill()
t.circle(100)
t.end_fill()

# 绘制四条腿
t.penup()
t.goto(-50, 0)
t.pendown()
t.fillcolor("green")
t.begin_fill()
t.circle(20, 180)
t.circle(10, 180)
t.end_fill()

t.penup()
t.goto(50, 0)
t.pendown()
t.fillcolor("green")
t.begin_fill()
t.circle(-20, 180)
t.circle(-10, 180)
t.end_fill()

# 绘制尾巴
t.penup()
t.goto(0, -50)
t.pendown()
t.fillcolor("green")
t.begin_fill()
t.circle(30)
t.end_fill()

# 隐藏海龟
t.hideturtle()

# 点击关闭画布
canvas.exitonclick()

运行上述代码后,会弹出一个画布,在画布上画出一只可爱的小海龟。

帮我写一段用python画一只小海龟的代码

原文地址: https://www.cveoy.top/t/topic/F9j 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录