用python画哆啦A梦的代码
时间: 2023-11-17 20:08:32 浏览: 103
这里给出一个使用Python的turtle模块绘制哆啦A梦的代码,你可以尝试运行。
```python
import turtle
# 设置画笔颜色和宽度
turtle.color('blue')
turtle.pensize(3)
# 画头部
turtle.fillcolor('blue')
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画耳朵
turtle.penup()
turtle.goto(-60, 160)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 160)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-40, 50)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 50)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.fillcolor('black')
turtle.penup()
turtle.goto(-40, 58)
turtle.pendown()
turtle.begin_fill()
turtle.circle(8)
turtle.end_fill()
turtle.penup()
turtle.goto(40, 58)
turtle.pendown()
turtle.begin_fill()
turtle.circle(8)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-50, -30)
turtle.pendown()
turtle.fillcolor('red')
turtle.begin_fill()
turtle.right(90)
turtle.circle(50, 180)
turtle.end_fill()
# 画身体
turtle.penup()
turtle.goto(-120, -150)
turtle.pendown()
turtle.fillcolor('blue')
turtle.begin_fill()
turtle.right(120)
turtle.circle(150, -60)
turtle.circle(20, -120)
turtle.circle(150, -60)
turtle.circle(20, -60)
turtle.end_fill()
# 画手
turtle.penup()
turtle.goto(-170, -100)
turtle.pendown()
turtle.fillcolor('blue')
turtle.begin_fill()
turtle.right(60)
turtle.circle(80, -60)
turtle.circle(20, -120)
turtle.circle(80, -60)
turtle.circle(20, -60)
turtle.end_fill()
turtle.penup()
turtle.goto(170, -100)
turtle.pendown()
turtle.fillcolor('blue')
turtle.begin_fill()
turtle.right(120)
turtle.circle(80, -60)
turtle.circle(20, -120)
turtle.circle(80, -60)
turtle.circle(20, -60)
turtle.end_fill()
# 画脚
turtle.penup()
turtle.goto(-70, -250)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.right(60)
turtle.circle(80, -60)
turtle.circle(20, -120)
turtle.circle(80, -60)
turtle.circle(20, -60)
turtle.end_fill()
turtle.penup()
turtle.goto(70, -250)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.right(120)
turtle.circle(80, -60)
turtle.circle(20, -120)
turtle.circle(80, -60)
turtle.circle(20, -60)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 点击窗口关闭
turtle.exitonclick()
```
运行后,窗口会弹出并绘制出哆啦A梦的图案。
阅读全文