turtle画靶子代码
时间: 2024-03-10 11:42:36 浏览: 195
turtle画图代码大全
当使用Python的turtle库来画靶子时,可以通过以下代码实现:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("white")
# 设置画笔颜色和粗细
turtle.pensize(3)
turtle.pencolor("black")
# 画外圆
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.circle(200)
# 画内圆
turtle.penup()
turtle.goto(0, -100)
turtle.pendown()
turtle.circle(100)
# 画十字线
turtle.penup()
turtle.goto(-200, 0)
turtle.pendown()
turtle.forward(400)
turtle.penup()
turtle.goto(0, -200)
turtle.setheading(90)
turtle.pendown()
turtle.forward(400)
# 关闭画笔
turtle.done()
```
阅读全文