基础python画图哆啦a梦
时间: 2023-10-28 07:01:23 浏览: 21
用Python画哆啦A梦
下面这个是基于 Python 的 Turtle 库实现的哆啦A梦绘制代码,你可以直接把它复制到 Python IDE 里运行试试。
```python
import turtle
# 设置画笔大小和颜色
turtle.pensize(4)
turtle.pencolor("blue")
# 画身体
turtle.fillcolor("#00a0de")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画脸
turtle.penup()
turtle.goto(0, 120)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(80)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-45, 170)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(45, 170)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 画鼻子
turtle.penup()
turtle.goto(0, 120)
turtle.pendown()
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-60, 70)
turtle.pendown()
turtle.pencolor("black")
turtle.right(45)
turtle.circle(70, -90)
# 画胡须
turtle.penup()
turtle.goto(-20, 90)
turtle.pendown()
turtle.goto(-100, 90)
turtle.penup()
turtle.goto(-20, 100)
turtle.pendown()
turtle.goto(-100, 110)
turtle.penup()
turtle.goto(-20, 80)
turtle.pendown()
turtle.goto(-100, 70)
turtle.penup()
turtle.goto(20, 90)
turtle.pendown()
turtle.goto(100, 90)
turtle.penup()
turtle.goto(20, 100)
turtle.pendown()
turtle.goto(100, 110)
turtle.penup()
turtle.goto(20, 80)
turtle.pendown()
turtle.goto(100, 70)
# 完成绘制
turtle.done()
```
运行结果如下所示:
![哆啦A梦](https://img-blog.csdn.net/20180521011251692)
阅读全文