使用python画出哭脸
时间: 2023-10-24 12:13:36 浏览: 225
python 利用turtle库绘制笑脸和哭脸的例子
5星 · 资源好评率100%
可以使用Python的turtle库来画出哭脸。下面是一个简单的示例代码:
```python
import turtle
# 设置画笔颜色和粗细
turtle.pensize(4)
turtle.pencolor('black')
# 画脸
turtle.circle(100)
# 画眼睛
turtle.penup()
turtle.goto(-40, 120)
turtle.pendown()
turtle.circle(20)
turtle.penup()
turtle.goto(40, 120)
turtle.pendown()
turtle.circle(20)
# 画嘴巴
turtle.penup()
turtle.goto(-60, 80)
turtle.pendown()
turtle.right(60)
turtle.circle(80, 120)
# 画眼泪
turtle.penup()
turtle.goto(-70, 90)
turtle.pendown()
turtle.right(30)
turtle.forward(20)
turtle.right(120)
turtle.forward(40)
turtle.right(120)
turtle.forward(40)
turtle.right(120)
turtle.forward(20)
turtle.penup()
turtle.goto(70, 90)
turtle.pendown()
turtle.left(30)
turtle.forward(20)
turtle.left(120)
turtle.forward(40)
turtle.left(120)
turtle.forward(40)
turtle.left(120)
turtle.forward(20)
turtle.done()
```
运行以上代码,就可以看到一个哭脸的画图结果了。
阅读全文