python代码:画图哆来a梦(用蓝色的线不上颜色)
时间: 2024-05-07 10:20:36 浏览: 11
下面是使用 Python 中的 turtle 库绘制哆来咪的代码,其中蓝色线条使用了 turtle 库中的 pencolor 方法:
```python
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 设置画笔大小和速度
turtle.pensize(5)
turtle.speed(10)
# 画脸
turtle.penup()
turtle.goto(0, -150)
turtle.pendown()
turtle.circle(150)
# 画眼睛
turtle.penup()
turtle.goto(-70, 60)
turtle.pendown()
turtle.circle(50)
turtle.penup()
turtle.goto(70, 60)
turtle.pendown()
turtle.circle(50)
# 画瞳孔
turtle.penup()
turtle.goto(-70, 60)
turtle.pendown()
turtle.circle(20)
turtle.penup()
turtle.goto(70, 60)
turtle.pendown()
turtle.circle(20)
# 画嘴巴
turtle.penup()
turtle.goto(-100, -50)
turtle.pendown()
turtle.right(60)
turtle.circle(120, 120)
# 画身体
turtle.penup()
turtle.goto(-200, -150)
turtle.pendown()
turtle.right(180)
turtle.forward(400)
turtle.right(90)
turtle.forward(250)
turtle.right(90)
turtle.forward(400)
turtle.right(90)
turtle.forward(250)
# 画腿
turtle.penup()
turtle.goto(-150, -300)
turtle.pendown()
turtle.right(30)
turtle.forward(200)
turtle.right(120)
turtle.forward(200)
# 画手
turtle.penup()
turtle.goto(-250, -50)
turtle.pendown()
turtle.right(20)
turtle.forward(200)
turtle.right(180)
turtle.forward(200)
turtle.right(140)
turtle.forward(200)
turtle.right(180)
turtle.forward(200)
# 隐藏画笔
turtle.hideturtle()
# 画布不关闭
turtle.done()
```
运行上述代码后,会弹出一个窗口,展示绘制出的哆来咪。
相关推荐
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)